2014-09-04 82 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(); 
相关问题