Skip to main content
All docs
V24.1

How to: Repeat Table Rows as Header

Word Processing Document API offers two options to control the appearance of large tables that span across multiple pages:

The code sample below toggles Repeat row as header and Break row across pages options in code:

View Example

using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer())
{
    AdjustTableRows(wordProcessor.Document);

    wordProcessor.SaveDocument("DocumentWithTables.docx",
         DocumentFormat.OpenXml);
}

private static void AdjustTableRows(Document document)
{
    Table table = document.Tables[0];
    table.BeginUpdate();

    //Repeat first three rows as header:
    table.Rows[0].RepeatAsHeaderRow = true;
    table.Rows[1].RepeatAsHeaderRow = true;
    table.Rows[2].RepeatAsHeaderRow = true;

    //Break last row across pages:
    table.LastRow.BreakAcrossPages = true;
    table.EndUpdate();
}