Free Support Forum -

Applying Custom paragraph styels in .net

Hi All,

As a business requirement I have to use the same style which client provided to us to generate Word report. I have to print a paragraph by applying a style called "Appendix 1". I used the same template and I am able to apply the same style but it is not getting reflected.

Here I am pasting the piece of code.

Aspose.Words.Style listStyle = wDoc.Styles["Appendix 1"];

Aspose.Words.Paragraph par = dbDoc.CurrentParagraph;


par.ParagraphFormat.Style = listStyle;

and also I used like this

//dbDoc.ParagraphFormat.StyleName = "Appendix 1";

//dbDoc.CurrentParagraph.ParagraphFormat.StyleName = "Appendix 1";

and also like this

/Style myStyle = wDoc.Styles.Add(StyleType.Paragraph, "MyStyle1");

//Aspose.Words.Lists.List list2 = wDoc.Lists.Add();

//dbDoc.ListFormat.List = list2;

But it is not worked for me

Please help to resolve this.


Thanks for your request. Could you please attach your input and output documents here for testing? I will investigate the problem and provide you more information.

Best regards,

Hi Andrey,

Thanks for quick reply. Here by I attached the template. I am using the same template to generate report. I have to use different styles for different paragraphs. like first paragraph should be with Appendix 1 Style and second paragraph should be with Appendix 2.

Please help me on this.


Yugandhar Simhadri


Thank you for additional information. Please try using the following code:

Document doc = new Document("C:\\Temp\\template.docx");

// Get styles

Style styleAppendix1 = doc.Styles["Appendix 1"];

Style styleAppendix2 = doc.Styles["Appendix 2"];

DocumentBuilder builder = new DocumentBuilder(doc);

// Apply stype Appendix 1

builder.ParagraphFormat.Style = styleAppendix1;

builder.Writeln("Appendix 1 Paragraph");

// Apply stype Appendix 2

builder.ParagraphFormat.Style = styleAppendix2;

builder.Writeln("Appendix 2 Paragraph");


Please let me know in case of any issues. I will be glad to help you.

Best regards,

Hi Andrey

Thank you very much. I used Font.Color and Font.Size also. for that reason these styles are not applying . Might be Styles are applying and then font is applying.

Once again thanks for your response.


Yugandhar Simhadri


It is perfect, that you already fond the reason of the problem. Please let me know in case of any issues, I will be glad to help you.

Best regards,