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

Hello,

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!
Gabriel

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?

Regards,
Mario

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!

Thanks,
Have a nice day!

Hello,

I have a similar issue with a report that contains multiple tables that could have different amount of data.
The approach suggested is not feasible because i already have some rows set as printing titles.

In the attached image i have set tables for each “Broadcaster section”.
The printing options that i use are
FitWorksheetWidthToPages = 1
PaperType = A4
PortraitMode = false
and the printing area uses all the used cells of each sheet
CellRange usedCellRange = worksheet.GetUsedCellRange(true);
worksheet.NamedRanges.SetPrintArea(usedCellRange);

Got the print options page height and was thinking of looping through all the sheet tables , get the height and when the height exceeds the available page height to add a horizontal page break. Yet with this approach the height that i receive for each excel table is not acurate as i assume it gets recalculated by the rendering engine.

Any ideas on how i can tackle this issue ?

Regards

Bogdan

Bogdan, I’m not sure I understood exactly what you want to achieve, do you want to have the header row of those “Broadcaster” sections repeated together with the rows that are already set as printing titles?

If yes, it looks like all “Broadcaster” sections have the same header row so you could just take the one from the first “Broadcaster” section and include it in the printing title.
If that is not a solution for you, can you explain why?

Also, you mentioned that you tried adding page breaks, how exactly would that solve your problem, can you explain that a bit?

Last, is it possible for you to send us your Excel file and describe or better yet show us what exactly would your desired output look like?