我需要比较office文件(doc、docx、xls、xlsx、ppt、pptx),如果两个比较文件是相同的,则只需要得到一个布尔值。
我找到了一个通过比较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\1.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\3.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);有什么解决办法吗?
发布于 2018-07-09 09:58:20
为你找到的:
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;https://stackoverflow.com/questions/51242652
复制相似问题