How to get 'Header Row' table style option using .NET


I have a simple Word template with a table in it. The table has Header Row option ticked.
When I load it with Aspose.Words 20.5 and on Debug I go to FirstRow’s RowFormat the HeadingFormat flag is set to false. (10.9 KB)

How can I know if the table I am loading has a first row that is a Heading?

See the code example:

var doc = new Document(@“InputFiles\BasicTableHeader.dotx”);



In your document, this option is not set. Please check the attached image for detail.
repeat header row.png (22.1 KB)

Hi Tahir,

I meant this option:
HeaderRow.png (1.4 KB)

How can I find it on Document object?



You can use Table.StyleOptions property to get the bit flags as shared in the image. We suggest you please check TableStyleOptions enumeration

In your document, the default setting is applied to table. So, this property will return ‘Default’.

Hi Tahir,

Thank you. Could you please provide us with a code sample that achieves the same as HeaderRow in Microsoft Word?



Please note that TableStyleOptions.FirstColumn | TableStyleOptions.RowBands | TableStyleOptions.FirstRow returns ‘Default’ value.

Following code example shows how to get TableStyleOptions.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();


// Set the table style used based of the unique style identifier
// Note that not all table styles are available when saving as .doc format
table.StyleIdentifier = StyleIdentifier.MediumShading1Accent1;

// Apply which features should be formatted by the style
table.StyleOptions =
    TableStyleOptions.FirstColumn | TableStyleOptions.RowBands | TableStyleOptions.LastColumn;

TableStyleOptions tableStyleOptions = table.StyleOptions;

Hi Tahir,

Can you tell me how can I know if a template that I load with Aspose.Words has that option ticked?

I mean how can I identify templates that have HeaderRow ticked in code using Document object from Aspose.Words?



Unfortunately, TableStyleOptions does not has ‘Header Row’ option. We have logged this feature request as WORDSNET-20643 in our issue tracking system. You will be notified via this forum thread once this feature is available.

We apologize for your inconvenience.


Please use the following code example to check if ‘Header Row’ is check or not. We have closed the issue WORDSNET-20647.

Document doc = new Document("BasicTableHeader.dotx");
Console.WriteLine((doc.FirstSection.Body.Tables[0].StyleOptions & TableStyleOptions.FirstRow) != 0);