Yuri N
Yuri N

Reputation: 76

How to export text correctly to Word using DocX library

I am trying simple to output some text from c# program to a new Word document but I have a weird problem: a lot of my output is coming upside down. Any word that doesn't end up with a letter is jumping to the end of the sentence. For example:

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

As you can see the sentences that end up with non letter are getting mixed up. I am using 2010 Office Word

Upvotes: 2

Views: 2545

Answers (1)

HonzsSedlomn
HonzsSedlomn

Reputation: 236

Try instead

Paragraph p1 = template.InsertParagraph();

use this

Paragraph p1 = doc.InsertParagraph();

Upvotes: 1

Related Questions