c#:比较 office 文档,如果文件相同则只得到 true/false 个结果
c#: Compare office documents and get just true/false results if files are identical
我需要比较 office 文件(doc、docx、xls、xlsx、ppt、pptx),结果 如果 2 个比较文件相同,则得到一个布尔值.
我找到了通过比较 2 生成结果文件的解决方案,但我不需要这个。
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.Visible = false;
wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
object wordTrue = (object)true;
object wordFalse = (object)false;
object fileToOpen = @"D:\Docs.docx";
object missing = Type.Missing;
Microsoft.Office.Interop.Word.Document doc1 = wordApp.Documents.Open(ref fileToOpen,
ref missing, ref wordTrue, 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 = @"D:\Docs.docx";
Microsoft.Office.Interop.Word.Document doc2 = wordApp.Documents.Open(ref fileToOpen1,
ref missing, ref wordTrue, 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);
Microsoft.Office.Interop.Word.Document doc = wordApp.CompareDocuments(doc1, doc2, WdCompareDestination.wdCompareDestinationNew, WdGranularity.wdGranularityWordLevel,
true, true, true, true, true, true, true, true, true, true, "", false);
有解决办法吗?
为您找到:
Microsoft.Office.Interop.Word.Document doc = wordApp.CompareDocuments(doc1, doc2, WdCompareDestination.wdCompareDestinationNew, WdGranularity.wdGranularityWordLevel,
true, true, true, true, true, true, true, true, true, true, "", false);
bool anyChanges = doc.Revisions.Count > 0;
我需要比较 office 文件(doc、docx、xls、xlsx、ppt、pptx),结果 如果 2 个比较文件相同,则得到一个布尔值.
我找到了通过比较 2 生成结果文件的解决方案,但我不需要这个。
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.Visible = false;
wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
object wordTrue = (object)true;
object wordFalse = (object)false;
object fileToOpen = @"D:\Docs.docx";
object missing = Type.Missing;
Microsoft.Office.Interop.Word.Document doc1 = wordApp.Documents.Open(ref fileToOpen,
ref missing, ref wordTrue, 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 = @"D:\Docs.docx";
Microsoft.Office.Interop.Word.Document doc2 = wordApp.Documents.Open(ref fileToOpen1,
ref missing, ref wordTrue, 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);
Microsoft.Office.Interop.Word.Document doc = wordApp.CompareDocuments(doc1, doc2, WdCompareDestination.wdCompareDestinationNew, WdGranularity.wdGranularityWordLevel,
true, true, true, true, true, true, true, true, true, true, "", false);
有解决办法吗?
为您找到:
Microsoft.Office.Interop.Word.Document doc = wordApp.CompareDocuments(doc1, doc2, WdCompareDestination.wdCompareDestinationNew, WdGranularity.wdGranularityWordLevel,
true, true, true, true, true, true, true, true, true, true, "", false);
bool anyChanges = doc.Revisions.Count > 0;