我正在从事一个网络项目,客户需要实现以下功能:首先上传一些MS Word文档,然后可以比较其中任意两个文档。
我想到的方法是先使用WEBDAV使文档可用,然后使用命令行打开两个文档,并选择“并排比较”选项。这样他就能够比较和修改两个文档。
问题在于,我找不到任何可以从命令提示符中运行以比较模式打开两个文档的命令。
如果您知道其他实现此功能的方法,请与我分享。
我正在从事一个网络项目,客户需要实现以下功能:首先上传一些MS Word文档,然后可以比较其中任意两个文档。
我想到的方法是先使用WEBDAV使文档可用,然后使用命令行打开两个文档,并选择“并排比较”选项。这样他就能够比较和修改两个文档。
问题在于,我找不到任何可以从命令提示符中运行以比较模式打开两个文档的命令。
如果您知道其他实现此功能的方法,请与我分享。
这可能是一种方法(适用于Visual Studio 2010)
我混合了以下两个链接
http://msdn.microsoft.com/en-us/library/vstudio/ee342218%28v=vs.100%29.aspx
在C#控制台项目中,我将它们混合在一起,并添加了引用:.NET --> Microsoft.Office.Interop.Word Version 14.0.0.0
以下是源代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
//using Office = Microsoft.Office.Core;
//using Microsoft.Office.Tools.Word;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Word.Application wordApp = new Word.Application();
wordApp.Visible = false;
object wordTrue = (object)true;
object wordFalse = (object)false;
object fileToOpen = @"C:\Temp\1.docx";
object missing = Type.Missing;
Word.Document doc1 = wordApp.Documents.Open(ref fileToOpen,
ref missing, ref wordFalse, ref wordFalse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref wordTrue, ref missing,
ref missing, ref missing, ref missing);
object fileToOpen1 = @"C:\Temp\2.docx";
Word.Document doc2 = wordApp.Documents.Open(ref fileToOpen1,
ref missing, ref wordFalse, ref wordFalse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
Word.Document doc = wordApp.CompareDocuments(doc1, doc2, Word.WdCompareDestination.wdCompareDestinationNew, Word.WdGranularity.wdGranularityWordLevel,
true, true, true, true, true, true, true, true, true, true, "", true);
doc1.Close(ref missing,ref missing,ref missing);
doc2.Close(ref missing,ref missing,ref missing);
wordApp.Visible = true;
}
}
}
待办事项: