Repeat Table Header Rows on Pages
Contents
[
Hide
]
See more details in the Working with Columns and Rows article of the Working with Tables documentation section.
A table can specify certain starting table rows to be used as header rows. This means that if the table spans over many pages, these rows will be repeated at the top of the table for each page. In Aspose.Words, you can apply this setting by using the HeadingFormat property.
The following code example shows how to build a table with rows that repeat on every page:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.startTable();
builder.getRowFormat().setHeadingFormat(true);
builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
builder.getCellFormat().setWidth(100);
builder.insertCell();
builder.writeln("Heading row 1");
builder.endRow();
builder.insertCell();
builder.writeln("Heading row 2");
builder.endRow();
builder.getCellFormat().setWidth(50);
builder.getParagraphFormat().clearFormatting();
// Insert some content so the table is long enough to continue onto the next page.
for (int i = 0; i < 50; i++)
{
builder.insertCell();
builder.getRowFormat().setHeadingFormat(false);
builder.write("Column 1 Text");
builder.insertCell();
builder.write("Column 2 Text");
builder.endRow();
}
doc.save(dataDir + "RepearHeaderRows.doc");
See also: