We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Custom styles for tables in word

I need to insert styles to a table in word. I know we can you use styleidentifier but I have seen this can only insert inbuilt styles in word. I want to use custom styles and not the inbuilt one. Is there a way I can achieve this?

Hi,


Thanks for your inquiry. You can use Table.Style property to apply a custom style to it. Please see the following code to achieve this:
Document doc = new Document(“C:\Temp\input.docx”);

Style tabCustomStyle = doc.getStyles().get(“Table_Style1”);
doc.getFirstSection().getBody().getTables().get(0).setStyle(tabCustomStyle);

doc.save(“C:\Temp\out.docx”);

I hope, this helps.

Best regards,