我使用VS2005,我需要創建許多.doc文件。 我的電腦(英特爾c2d6600與2GB內存)可以轉換爲10個文件/分鐘,這對我來說非常慢。 我應該怎麼做才能提高性能?在c#應用程序中與Word非常緩慢的互操作
我的代碼:
oWord = new Word.Application();
oMissing = System.Reflection.Missing.Value;
oDoc = this._oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
...
//Do something
...
//save rtf
object fileName = this.FileRtf;
object fileFormat = Word.WdSaveFormat.wdFormatRTF;
object savechanges = false;
oDoc.SaveAs(ref fileName, ref fileFormat, 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);
oWord.Quit(ref savechanges, ref oMissing, ref oMissing);
Word.Paragraph oPara; ...; oPara.Range.InsertParagraphAfter()的工作很慢,但我在每個文檔中都有很多這樣的操作。 :( – mystdeim 2010-12-03 09:55:01