Header repeating on each page for multi page table

Hi there,

I’m working on report that has a series of tables that span multiple pages. How do I set up the merge fields so that the header of the table will appear at the top of every page the tables is on?

thanks

Brendan

Found it: https://support.microsoft.com/en-us/office/repeat-table-header-on-subsequent-pages-2ff677e0-3150-464a-a283-fa52794b4b41?ui=en-us&rs=en-us&ad=us

Hi Brendan,

Thanks for your inquiry. Please set the value of RowFormat.HeadingFormat property as true for the first row of table. When this property is true, row is repeated as a table heading on every page when the table spans more than one page.

Please check following code example for your kind reference. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.StartTable();
builder.RowFormat.HeadingFormat = true;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
builder.CellFormat.Width = 100;
builder.InsertCell();
builder.Writeln("Heading row 1");
builder.EndRow();
builder.InsertCell();
builder.Writeln("Heading row 2");
builder.EndRow();
builder.CellFormat.Width = 50;
builder.ParagraphFormat.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.RowFormat.HeadingFormat = false;
    builder.Write("Column 1 Text");
    builder.InsertCell();
    builder.Write("Column 2 Text");
    builder.EndRow();
}
doc.Save(MyDir + "Table.HeadingRow Out.doc");