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

紧急:c#中将rtf格式文件插入到word中!急!!!!!!!!!!!!!!
我在winform中用RichTextBox生成了rtf格式的文件,如下:
{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq2\fcharset134 \'cb\'ce\'cc\'e5;}{\f1\froman\fprq2\fcharset0 Times New Roman;}{\f2\fnil\fcharset134 \'cb\'ce\'cc\'e5;}}
\viewkind4\uc1\trowd\trgaph108\trleft-108\cellx1109\cellx2326\cellx3543\cellx4760\cellx5978\cellx7196\cellx8414\pard\intbl\kerning2\b\f0\fs21\'cf\'ee\'c4\'bf\cell\'c3\'e8\'ca\'f6\f1 / ID \f0\'ba\'c5\'c2\'eb\cell\'ca\'fd\'c1\'bf\cell\'b5\'a5\'ce\'bb\cell\'b5\'a5\'ce\'bb\'bc\'db\'b8\'f1\f1 RMB\f0\cell\'bd\'f0\'b6\'ee\f1 RMB\f0\cell\'b2\'fa\'c6\'b7\'b7\'d6\'c0\'e0\'ba\'c5\cell\row
\intbl\cell\'ba\'cf\'bc\'c6\cell\cell\cell\cell\f1 0\f0\cell\cell\row
\pard\lang2052\kerning0\b0\f2\fs18\par
}
我现在需要在c#中,将上面格式的文件插入到Word文件中,请问该怎么操作啊??谢谢了!!!!!

------解决方案--------------------
關注
------解决方案--------------------
像一堆乱码,不懂!
------解决方案--------------------
为什么要用RichTextBox生成rtf的格式呢,说说看,也许用其他的想法更好呢

------解决方案--------------------
用流?
------解决方案--------------------
这个打开WORD的,
导入COM库:Microsoft word 11.0 Object Library.
引用里面就增加了:using Microsoft.Office.Interop.Word;
C# code

            object oMissing = System.Reflection.Missing.Value;
            Word._Application oWord;
            Word._Document oDoc;
            oWord = new Word.Application();
            oWord.Visible = true;
            object fileName = @"E:\CCCXCXX\TestDoc.doc";  //这里可以改成你的rtf文件路径
            oDoc = oWord.Documents.Open(ref fileName,
            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
            ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);