从单词中读取格式化文本 [英] reading formatted text from word

查看:81
本文介绍了从单词中读取格式化文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的表格中有两个word文档和两个文本区域。我想要两个比较两个文档,并加载原始文档和相应文本区域中的更改,并突出显示更改。这该怎么做?我进行了比较和加载,但没有突出显示差异





Hi all,
I have two word documents and two text area in my form. I want two compare two documents and load the original and document with changes in corresponding text areas with highlighting the changes. How to do this? I compared and loaded but it is not highlighting the difference


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Office.Tools.Word;
using System.Data;
using System.Windows.Forms;
using Microsoft.Office.Core;




namespace edit
{
    public partial class compare : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
           
            Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
            wordApp.Visible = false;
           
            object wordTrue = (object)true;
            object wordFalse = (object)false;
            object fileToOpen = @"C:\Documents and Settings\divyar.DNISC\Desktop\doc12.rtf";
            object missing = Type.Missing;
            
            Microsoft.Office.Interop.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:\Documents and Settings\divyar.DNISC\Desktop\doc5.rtf";
           
            Microsoft.Office.Interop.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);
         
          
            Microsoft.Office.Interop.Word.Document doc = wordApp.CompareDocuments(doc1, doc2, Microsoft.Office.Interop.Word.WdCompareDestination.wdCompareDestinationRevised, Microsoft.Office.Interop.Word.WdGranularity.wdGranularityWordLevel,true, true, true, true, true, true, true, true, true, true, "", false);
            Editor1.Content = "hai";
            doc.ActiveWindow.Selection.WholeStory();
            doc.ShowRevisions = true;
           

            doc.ActiveWindow.Selection.Copy();
           
            string con = doc.Content.Text;
            TextBox1.Text = con;
           
           

         

            
            wordApp.Visible = false;
            doc1.Close(ref missing, ref missing, ref missing);
            doc2.Close(ref missing,ref missing,ref missing);
            
           
           
       

           
        }
    }
}

推荐答案

请参考这些主题,可能会对你有所帮助

http://stackoverflow.com/questions/4224649/diff-2-open-xml-word-documents [ ^ ]

http://stackoverflow.com/questions/10294789/a-net-winforms-component-to-compare-双文件 [ ^ ]
Please refer these threads, might help you
http://stackoverflow.com/questions/4224649/diff-2-open-xml-word-documents[^]
http://stackoverflow.com/questions/10294789/a-net-winforms-component-to-compare-two-documents[^]


hi
访问此链接





[ ^ ]


这篇关于从单词中读取格式化文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆