Cannot read style properties of a table style

I need to find out what the border and colour properties of a table style are at run time.

The style object itself does not provide any of this information. To work around this I have tried creating a small table and applying a style to it so that I can read the colour and border properties of the table.

When I save the document with the table in it and open it in Word I can see the style applied but when I investigate the properties of the table programatically I only see default values for cell and row borders and shading.

Sample Code.

Document d = new Document();
DocumentBuilder db = new DocumentBuilder(d);
var table = db.StartTable();
db.InsertCell();
table.StyleOptions = Aspose.Words.Tables.TableStyleOptions.ColumnBands |
Aspose.Words.Tables.TableStyleOptions.FirstColumn |
Aspose.Words.Tables.TableStyleOptions.FirstRow |
Aspose.Words.Tables.TableStyleOptions.LastColumn |
Aspose.Words.Tables.TableStyleOptions.LastRow |
Aspose.Words.Tables.TableStyleOptions.RowBands;
table.StyleIdentifier = StyleIdentifier.MediumShading2Accent3;
db.Write(“11”);
db.InsertCell();
db.Write(“21”);
db.EndRow();
db.InsertCell();
db.Write(“12”);
db.InsertCell();
db.Write(“22”);
db.EndRow();
db.EndTable();

d.Save(@“c:\temp\temp.docx”);

How can I read the colour and border properties of a table style?

Hi Spencer,


Thanks for your inquiry.

Your on the right lines, please try calling the Document.ExpandTableStylesToDirectFormatting first. After calling this method you should be able to query the formatting on cells and rows and find the formatting applied by the table style this way.

If we can help you with anything else, please feel free to ask.

Thanks