Free Support Forum - aspose.com

Problem with ParagraphFormat.StyleName

Hi,

Im generating a word document thats get value from database. im will get the text as question and answer. so i have set question’s - ParagraphFormat.StyleName with Heading2, Heading3… and answer’s ParagraphFormat.StyleName = “Body Text”.

builder.Font.Name = “Arial”;

builder.Font.Bold = true;

builder.ParagraphFormat.StyleName = “Heading 2”;

builder.Font.Color = System.Drawing.Color.Red;

builder.Writeln("1.1 " + “Question as heading”);

builder.Font.ClearFormatting();
builder.Font.Name = “Arial”;

builder.Font.Bold = true;

builder.ParagraphFormat.StyleName = “Body Text”; //or Normal

builder.Font.Color = System.Drawing.Color.Red;

builder.Writeln("1.1 " + “Answer as description”);


But i notice that after the document was generated i found some section of the answer text are still formatted as “Heading” sections.
So it gives us problem when TOC was generated. This description part also comes in the TOC.

Could u please explain me how to resolve the problem.

Thanks,

Kannadasan. A

Hi,

Please try to use builder.ParagraphFormat.ClearFormatting along with builder.Font.ClearFormatting.