GemBox Support Forum

How to add table header on each page when saving a long table inside excel as pdf


I am filling a template file from excel using gembox and the result needs to be saved as a pdf.
Inside here I am having a pretty long table. The data inside is spanning on multiple pages and on each new page I want to have the column headers for easy readability when printing.

As the forum allows me to upload only one media link, here is the link to a word document in google drive containing all the images that I added here and that the forum wouldnt let me post: click (great workaround)

This is how the printing currently looks like, using a DataTable and a Table without the table header on the next page (picture 1 from the word document).

Inside Excel there is an option to set, for a table, the rows to have on each new page (picture 2 from the word document)

This setting in the excel template will result in this pdf being generated: (picture 3 from the word document)

I would like to know if there is a way to do this programmatically in Gembox.SpreadSheet (i think using Table class in Gembox.Document has this capability) and print the DataTable header or the Table header on each page without doing any additional work from Excel

Thank you!

Hi Gabriel,

In short, you’re looking for SetPrintTitles method.

For instance, please check the Print Titles and Area example.

Does this solve your issue?


Yep, seems to be working, don’t know how I missed that.

Was thinking that maybe it would be some specific setting in the Table/DataTable that would create the Print Titles automatically but this seems to work just fine!

Have a nice day!