Free Support Forum -

"RowFormat.HeadingFormat = true" doesn't work

Aspose.Words.Tables.Table currentTable = docBuilder.StartTable();
docBuilder.RowFormat.Height = 20;
docBuilder.CellFormat.Width = 80;
docBuilder.RowFormat.HeadingFormat = true;
for (int m = 0; m < subtabledata.Rows.Count; m++)
DataRow datarow = subtabledata.Rows[m];
RowFormat rowf1 = docBuilder.RowFormat;
rowf1.Height = 20;

                                    for (int j = 1; j < subtabledata.Columns.Count; j++)
                                        docBuilder.CellFormat.HorizontalMerge = CellMerge.None;
                                        docBuilder.CellFormat.VerticalMerge = CellMerge.None;
                                        docBuilder.CellFormat.Width = 80;
                                        docBuilder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
                                        docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                                        docBuilder.CellFormat.FitText = true;
                                        if (j == 1)
                                            docBuilder.RowFormat.HeadingFormat = false;


Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Thanks for your reply. My application is a web application, let me sort it out and find the problem.Thank you.

I fined the problem. If the bookmark in a table’s td of a word template, I move to this bookmark and build a table by using docBuilder.StartTable() and set currentTable.FirstRow.RowFormat.HeadingFormat = true. The table header will not appear on every page. How to resolve this problem? If the bookmark doesn’t in a table, table header will appear on every page. Thank you! (13.8 KB)

我找到问题了,如果书签是在一个Word模板的表格的单元格内,我用代码找到这个书签,然后用代码形成表格的时候,设置HeadingFormat = true,不起作用,表头不会在每页出现。如果这个书签不在表格内的话,表头会出现在每个页面上。这个问题怎么解决呢?谢谢


Thanks for your inquiry. The third row of table contains bookmark. You can repeat this row as header in output document using the following code example. You can insert the table in this row or some other content to repeat it on every page of document.

Document doc = new Document(MyDir + "222.doc");
doc.FirstSection.Body.Tables[0].Rows[2].RowFormat.HeadingFormat = true; 

doc.Save(MyDir + "18.11.docx");

If you set RowFormat.HeadingFormat property for a row of nested table, it will not work. This is expected behavior.

If you still face problem, please ZIP and attach your expected output Word document here for our reference. We will then provide you more information about your query.

OK,Thank you!