Repeated Header rows for table in .DOC

Hi

I have to read tables from .DOC file and repeat the header rows for the tables whose rows breaks to the next page due to limited space on the current page.

Kindly help me with this table formatting issue.

Regards,
Prabhaker Kr

Hi Prabhaker,

Thanks for your inquiry. Please read following documentation links for your kind reference. Hope this helps you.
https://docs.aspose.com/words/java/working-with-columns-and-rows/
https://docs.aspose.com/words/java/keeping-tables-and-rows-from-breaking-across-pages/

Please let us know if you have any more queries.

Hi,

Thank you for the references.I went through the references given by you. Now I am able to set the non-breaking of the table.

But the reference for setting the header row to repeat is for creating a table and setting it. But I want the header row to be repeated for a table already present in a DOC and spans to more than 1 page.

Which API’s to repeat the header row in this case ?

Regards.
Prabhaker Kumar

Hi Prabhaker,

Thanks for your inquiry. You can repeat the table row of existing table in the document using Row.RowFormat.HeadingFormat property. Please set the value of this property to True. See the following code snippet for your reference.

Document doc = new Document(MyDir + "in.docx");
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
table.getFirstRow().getRowFormat().setHeadingFormat(true);

If you still face problem, please attach your input Word document here for testing. I will investigate the issue on my side and provide you more information.

Hi Tahir,

Thank you for the reference. It worked. I have one more requirement with the Table header row repeat. There are some tables with more than one header row. In that case only the first header row is repeated to every pages. Is there any way to get the entire header row and repeat those instead of only the first header row.

Thanks & Regards,
Prabhaker Kumar

Hi Prabhaker,

Thanks for your inquiry. Could you please attach your input and expected output Word documents here for our reference? Please manually create your expected output Word document using Microsoft Word. 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,

Thank you for the reply. I have attached the document with the details of the requirement.

Kindly note that the number/style/layout of header rows in the table in the attached document may vary.

Thanks & Regards,
Prabhaker Kr

Hi Prabhaker,

Thanks for your inquiry. You just need to set the value of RowFormat.HeadingFormat property as true for first two rows of table. Please check the highlighted code snippet. I have attached the output document with this post for your kind reference.

Please let us know if you have any more queries.

Document doc = new Document(MyDir + "HeaderRepeat.docx");
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
table.getRows().get(0).getRowFormat().setHeadingFormat(true);
table.getRows().get(1).getRowFormat().setHeadingFormat(true);
doc.save(MyDir + "Out.docx");