I’m using the Aspose.Cells library to generate an Excel report, and I’m looking for a way to accurately calculate the page breaks so I can insert some rows after each break.
I tried using the GetPrintingPageBreaks function with the following options:
AllColumnsInOnePagePerSheet = false
IsCellAutoFit = true
However, the page breaks I’m getting are not correct. Any suggestions on how to resolve this issue or what might be causing the incorrect page breaks?
I’ve attached a zip file containing a single workbook. The workbook includes a sample sheet named “Invoice Wise Sales Register,” which has some data relevant to the issue I’m facing with page break calculations.
@Abhishek1997
By testing on the latest version v24.9 using sample files and the following sample code, we can reproduce the issue. When the system display is set to 100%, Excel print preview has 58 pages, while Cells receives 55 pages. Please refer to the attachment. result.png (38.6 KB)
The sample code as follows:
Console.WriteLine("version: " + CellsHelper.GetVersion());
Workbook wb = new Workbook(filePath + "SampleReport.xlsx");
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.AllColumnsInOnePagePerSheet = false;
WorkbookRender render = new WorkbookRender(wb, options);
Console.WriteLine(render.PageCount);
The output result:
version: 24.9
55
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-56855
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
I have checked the page breaks in Excel, the page breaks are same as the one generated by Aspose.Cells. Please refer to the pdf file generated by Excel to check the page breaks. SampleReport_SavedByExcel.pdf (1.2 MB)
The only difference is that the last blank page is not outputed in Aspose.Cells.
Please note, Excel may have different page breaks on Windows with different display setting in system settings. Aspose.Cells takes the result of Excel on Windows with 100% display setting as the rule.
Thanks for your reply. I’ve attached my sample code showing how I’m getting the page breaks and the results I’m getting. Could you please help me identify where I’m making a mistake?