How to modify a native Table Style (not copy it to cells)


I’m trying to create a table within a new Word document and retain proper style association to allow the user to download the created document and then easily make manual modifications with MS Word.

I want to apply a modified native Table Style to a table:

table.StyleIdentifier = StyleIdentifier.GridTable6ColorfulAccent3;
table.StyleOptions = TableStyleOptions.RowBands | TableStyleOptions.FirstColumn | TableStyleOptions.FirstRow;

Basically, I’d to know how to access and modify those MS word options (see attachment).

image.png (23.6 KB)

I tried to access the TableStyle using the following code but cannot seem to have access to the options from the image.

style = builder.Document.Styles[StyleIdentifier.GridTable6ColorfulAccent3];
var tblStyle = style as TableStyle;
// tblStyle.HeaderRow.Font.Color = ...

I am aware of the function doc.ExpandTableStylesToDirectFormatting(); but I cannot use that because that would mean that each table style would become local table cell styling. So, if I had, say 5 tables, and wanted to later manually modify the header row shading and font color from MS Word, I would have to individually edit each of those 5 tables instead of just editing the “Grid Table 6 Colorful Accent 3” style.

Can you help? Is that supported? If not, will it be? This is pretty important to create clean Word documents.


p.s. Creating a new Table Style from scratch would also be OK, but more work then modifying a native style.

Somewhat related posts (though different):


Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we have logged this feature request as WORDSNET-18400 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-18400) have been fixed in this Aspose.Words for .NET 19.6 update and this Aspose.Words for Java 19.6 update.

1 Like