You can configure rows in a worksheet in order to repeat them at the top by using the PrintTitleRows property and at the bottom using the PrintTailRows property of the IPageSetup interface.
While exporting a spreadsheet with repeating rows to a PDF file, the tail rows will be exported only when its index is larger than the page's last row's index. Otherwise, the tail row is ignored. For instance, if the Print Area is "B5:H23" and the top repeating row is "$3:$3"; it will print "$3:$3" repeatedly on each page. However, if users set the top repeating row to "$30:$30", then it will not print "$30:$30" (because the row index is larger than print area).
Refer to the following example code in order to configure rows to repeat at the bottom.
C# |
Copy Code |
---|---|
// Initialize workbook Workbook workbook = new Workbook(); // Fetch default worksheet IWorksheet worksheet = workbook.Worksheets[0]; // Populating cells in worksheet var range = worksheet.Range["A1:J200"]; for (int i = 0; i < 200; i++) for (int j = 0; j < 10; j++) { range.Cells[i, j].Value = i.ToString(); range.Cells[199, j].Value = "Row 199"; } //Repeat Row 200 at the bottom of each page while saving PDF worksheet.PageSetup.PrintTailRows = "$200:$200"; // Saving workbook to PDF workbook.Save(@"ConfigureTailRows.pdf", SaveFileFormat.Pdf); |
Refer to the following example code in order to configure rows to repeat at the top.
C# |
Copy Code |
---|---|
//Set rows to repeat at top worksheet.PageSetup.PrintTitleRows = "$5:$10"; |