2014-09-04 86 views
2

我想簡單地從c#程序輸出一些文本到一個新的Word文檔,但我有一個奇怪的問題:很多我的輸出是顛倒的。任何不以字母結尾的單詞都會跳到句尾。例如:如何將文本正確地導出到Word使用DocX庫

DocX doc= DocX.Create(filePath); 
Paragraph p1 = template.InsertParagraph(); 
p1.AppendLine("This line contains a ").Append("bold").Bold().Append(" word."); 
p1.AppendLine("Here is example with question mark?"); 
p1.AppendLine(); 
p1.AppendLine("Can you help me figure it out?"); 
p1.AppendLine(); 

Output of the code

Output of the code

正如你可以看到,最終與非字母的句子越來越混淆。我使用的2010 Office Word中

+0

不能在這裏重現該問題,你的代碼 – har07 2014-09-04 07:22:20

+0

是否使用OFFICE 2010,以及工作對我罰款? – 2014-09-04 08:01:40

+0

您使用的是什麼版本的庫? .NET版本? – MarkKGreenway 2014-09-04 13:04:50

回答

1

嘗試,而不是

Paragraph p1 = template.InsertParagraph(); 

使用本

Paragraph p1 = doc.InsertParagraph(); 
相關問題