Reputation: 31
How do you get the row header to repeat itself
this is a simular question: With POI Word API, how to repeat a table heading on subsequent pages?
The code that i am currently running doing is this
XWPFTable contentTable = pXWPFDocument.createTable(50, 6);
List<XWPFTableRow> rows = contentTable.getRows();
XWPPFTableRow firstRow = rows.get(0);
firstRow.setRepeatHeader(true);
List<XWPFTableCell> tableCells = firstRow.getTableCells();
//Some code to fill the first row (header)
//I skip the first row (the header row) and continue with the rest
for (int i = 1; i < rows.size(); i++)
{
XWPFTableRow row = rows.get(i);
addDummy(row);
}
As you can see i have marked the first row with a setRepeatHeader. But when i have a new page the table header is not repeated. What did i do wrong? Please help me. Thx in advance!
Upvotes: 1
Views: 1840
Reputation: 31
I found the solution: the api info defines the following: "NOTE - for a row to be repeated, all preceding rows in the table must also be repeated."
This information can be misleading (as it was for me) the method setRepeatHeader ONLY has to be defined on the firstRow (the headerRow)
What I did wrong was that i did a setRepeatHeader for every dummyRow
Upvotes: 2