C# 用C在WPF中以格式显示数学方程#

C# 用C在WPF中以格式显示数学方程#,c#,asp.net,wpf,data-binding,ms-word,C#,Asp.net,Wpf,Data Binding,Ms Word,我有一个word文件,里面有2-3个数学方程。我成功地检索到了它,但无论如何,我都无法用C#将它绑定到WPF中的word文件中。 提前谢谢 private XpsDocument ConvertWordDocToXPSDoc(string wordDocName, string xpsDocName) { // Create a WordApplication and add Document to it Microsoft.Office.Inter

我有一个word文件,里面有2-3个数学方程。我成功地检索到了它,但无论如何,我都无法用C#将它绑定到WPF中的word文件中。 提前谢谢

private XpsDocument ConvertWordDocToXPSDoc(string wordDocName, string xpsDocName)
     {
         // Create a WordApplication and add Document to it
         Microsoft.Office.Interop.Word.Application
             wordApplication = new Microsoft.Office.Interop.Word.Application();
         wordApplication.Documents.Add(wordDocName);


         Document doc = wordApplication.ActiveDocument;
         // You must ensure you have Microsoft.Office.Interop.Word.Dll version 12.
         // Version 11 or previous versions do not have WdSaveFormat.wdFormatXPS option
         try
         {
             //doc.SaveAs(xpsDocName, WdSaveFormat.wdFormatXPS);
             wordApplication.Quit();
             string strRetval = "";
             System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
             Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
             object miss = System.Reflection.Missing.Value;
             object path = wordDocName;//@"C:\DOC\myDocument.docx";
             object readOnly = true;
             Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
             List<string> lines = new List<string>();
             string totaltext = "";
             for (int i = 0; i < docs.Paragraphs.Count; i++)
             {
                 if (!string.IsNullOrEmpty(docs.Paragraphs[i + 1].Range.Text.ToString().Replace("\r", string.Empty)))
                 {
                     totaltext = " \r\n " + docs.Paragraphs[i + 1].Range.Text.ToString();
                     lines.Add(totaltext);

                 }
             }
             //In totaltext i will get text as well as mathematical expression. Text showing correctly but mathematical equation lost format wile binding it to textblock.
             txtFileBlock.Text = totaltext;

             XpsDocument xpsDoc = new XpsDocument(xpsDocName, System.IO.FileAccess.Read);
             return xpsDoc;
         }
         catch (Exception exp)
         {
             string str = exp.Message;
         }
         return null;
     }
私有XpsDocument ConvertWordDocToXPSDoc(字符串wordDocName,字符串xpsDocName)
{
//创建WordApplication并向其添加文档
Microsoft.Office.Interop.Word.Application
wordApplication=新的Microsoft.Office.Interop.Word.Application();
wordApplication.Documents.Add(wordDocName);
Document doc=wordApplication.ActiveDocument;
//您必须确保拥有Microsoft.Office.Interop.Word.Dll版本12。
//版本11或以前的版本没有WdSaveFormat.wdFormatXPS选项
尝试
{
//doc.SaveAs(xpsDocName,WdSaveFormat.wdFormatXPS);
wordApplication.Quit();
字符串stretval=“”;
System.Text.StringBuilder strBuilder=new System.Text.StringBuilder();
Microsoft.Office.Interop.Word.Application Word=新的Microsoft.Office.Interop.Word.Application();
对象未命中=System.Reflection.Missing.Value;
对象路径=wordDocName;/@“C:\DOC\myDocument.docx”;
对象只读=真;
Microsoft.Office.Interop.Word.Document docs=Word.Documents.Open(参考路径,参考未命中,参考只读,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中,参考未命中);
列表行=新列表();
字符串totaltext=“”;
对于(int i=0;i
下面是我在doc文件中的公式。

但情况如下:

我认为没有人能给你一个通用的方法

请查看以下主题,这些主题可能会为您提供一条道路:


编写一些代码,说明你是如何尝试实现的,以及你成功了多少。为什么你有asp.net标签?请写下你从word文件中检索到的数据,看看结果。你的态度不适合收回答案,这里的每个人都在努力帮助你。呃……你正在尝试以文本的形式阅读word中的数学,并以与word相同的方式在应用程序中显示它,对吗?