You can configure rows in a worksheet in order to repeat them at the top by using the setPrintTitleRows() method and at the bottom by using the setPrintTailRows() method 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.
Java |
Copy Code |
---|---|
// Initialize workbook Workbook workbook = new Workbook(); // Fetch default worksheet IWorksheet worksheet = workbook.getWorksheets().get(0); // Populating cells in worksheet for (int i = 0; i < 200; i++) for (int j = 0; j < 10; j++) { worksheet.getRange(i, j).setValue(i); worksheet.getRange(199, j).setValue("Row 199"); } // Repeat Row 200 at the bottom of each page while saving pdf worksheet.getPageSetup().setPrintTailRows("$200:$200"); // Saving workbook to pdf workbook.save("ConfigureTailRows.pdf", SaveFileFormat.Pdf); |
In order to configure rows to repeat at top, refer to the following example code.
Java |
Copy Code |
---|---|
// Set rows to repeat at top worksheet.getPageSetup().setPrintTitleRows("$5:$10"); |