繁体   English   中英

如何将C#中的2个单词文档与Ms-office installedversion进行比较

[英]How to compare 2 word documents in C# with out Ms-office installedversion

我想比较c#sideby中的2个单词文档,并在word文档(.doc或.docx)中获取不同的文本或句子作为报告,报告可以并排突出显示差异并使用以下代码

Application wordApp = new Application();

        wordApp.Visible = true;

        object wordTrue = (object)true;

        object wordFalse = (object)false;

        object fileToOpen = @"D:\MyWorks\test1.doc";

        object missing = Type.Missing;

        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 = @"D:\MyWorks\test2.doc";

        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);



        Document doc = wordApp.CompareDocuments(doc1, doc2, WdCompareDestination.wdCompareDestinationNew, WdGranularity.wdGranularityWordLevel,

            true, true, true, true, true, true, true, true, true, true, "", true);

上面的代码给出了以下错误

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

请帮助我在这方面,我想在系统中运行这个不包含ms-office安装版本plese提供一些gudilines

谢谢

SREE

如果没有安装Office,则无法使用Microsoft Office Interop - 这是不可能的。 此外:您在服务器环境中,Microsoft不推荐运行Office,因为存在大量线程问题,有时来自Office的消息框将挂起您的线程。

您有两种选择: - 使用Office Open XML Sdk来比较文档,但这是很多工作,因为它与Interop非常不同。 有免费的书“Open XML Explained”可以帮助您入门。 - 使用一个压缩Office Open XMl SDK的库 - 我从来没有使用过这些库,所以我不能给你一个建议。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM