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

Free Support Forum - aspose.com

Table style is applied incorrectly to Table in Word document using Java

Hi - I have asked this before but have not seen any update.
I use builder to construct a word table and also assign a know style name to it. This works fine however the table style is set with no header row and I need to set row 1 to be a header row.

If i set the rows as I build then when I apply stylename to table it looses the row setting (How word behaves)
However in word having set the table style I can manually set row 1 to be a header row.

How can I do this with Aspose please ?



Please share the forum thread. We will then answer your query according to your requirement.

Could you please ZIP and attach your input, problematic and expected output documents along with code example to reproduce this issue at our end? We will investigate the issue and provide you more information on it. Thanks for your cooperation.

Hi Tahir,
To recap. The attached java code uses builder to:

Open a templat.docm
Build a new docm containing 1 table
The table has 11 rows of 3 cells
Row 1 should be marked as a header row
template.docm is the template that contains the table style “Fees and Commission”
resultDocumentLatest.docm the result using aspose-words-19.11-jdk17.jar
resultDocumentOldest.docm using Aspose.Words.jdk16.jar
example.java & main.java the java code
When you run this please set ;
Boolean runLatestAsposeLib = false; and ensure Aspose.Words.jdk16.jar is being used
Boolean runLatestAsposeLib = true; and ensure spose-words-19.11-jdk17.jaris being used
You will note that this was working and now is not. Open in word and table props on row 1

Hope this helps.

JanjansFiles.zip (886.5 KB)


When we open the documents in MS Word and update the style ‘Fees and Commission’ for both output document, the table border is changed.

Could you please ZIP and attach your expected output document? We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

Hi Tahir,
Maybe a misunderstanding but the border & indent is not of concern.
The result I am looking for is produced in oldest docm in that row 1 is correctly marked as a header row.
The same code does not produce the same result using the latest Aspose Words library?



If we open the document ‘resultDocumentOldest.docm’ in MS Word and apply the style ‘Fees and Commission’, the table border is changed to none.

You can use Table.SetBorders method to set all table borders to the specified line style, width and color.

Not sure that we are talking the same subject. I am saying that the latest Apose Words produces different results (with regard to row 1 header property) than the older release which removes the backward compatibility.
Is there a preferred way to set a row header property and apply a table style


Please note that Aspose.Words mimics the behavior of MS Word. Please open the ‘template.docm’ in MS Word, create a table and apply the style Fees and Commission. You will notice that there is no table border and first row is not set as heading. Please check the attached image for detail. Fees and Commission.png (20.4 KB)

The latest version of Aspose.Words 20.6 does not set the table header. It is expected behavior. We suggest you please get the first row of table and set the value of RowFormat.HeadingFormat property as true to get the desired output.

If you want the table’s border as shared in resultDocumentOldest.docm, we suggest you please update the table’s style according to your requirement.

Hope this answers your query. Please let us know if you have any more queries.