日期:2014-05-18  浏览次数:20528 次

进来看下,各位,一个小问题...
想把WORD模板的内容(包括格式)用程序取出来,显示在编辑器里(如FreeTextBox里)来编辑WORD模板   用的代码如下
using   System.Text;
using   System.IO;
using   Word;
using   System.Reflection;
....
  string   WordPhysicsPath   =   @ "F:\WebSite1\test.doc ";
                ApplicationClass   app   =   new   ApplicationClass();
                object   fileName   =   WordPhysicsPath;
                object   optional   =   Missing.Value;
                object   visible   =   true;
                if   (File.Exists(WordPhysicsPath))
                {
                        Word.Document   doc   =   app.Documents.Open(ref       fileName,   ref       optional,   ref       optional,   ref       optional,   ref       optional,   ref       optional,   ref       optional,   ref       optional,   ref       optional,   ref       optional,   ref       optional,   ref       optional,   ref       visible,   ref       optional,   ref       optional,   ref       optional);
                        object   first   =   0;
                        object   units   =   WdUnits.wdCharacter;
                        object   last   =   doc.Characters.Count;

                        this.txtContent.Text   =   doc.Range(ref       first,   ref       last).Text;
                        object   saveChanges   =   WdSaveOptions.wdDoNotSaveChanges;
                        object   originalFormat   =   Missing.Value;
                        object   routeDocument   =   Missing.Value;
                        app.Quit(ref       saveChanges,   ref       originalFormat,   ref       routeDocument);

                }      
这样只是取到了文字内容,没有格式,怎么可以把WORD原样格式和内容显示在编辑器里呢?

------解决方案--------------------
还是把Word模板改成HTML模板,这样要好做得多。
------解决方案--------------------
俺不懂啊 帮顶下吧 记得给分哦
------解决方案--------------------
帮顶!关注!
------解决方案--------------------
顶!
------解决方案--------------------
复制粘贴