Free Support Forum - aspose.com

GetPrintingPageBreaks gives incorrect values

Hi,

I have a problem with Worksheet.GetPrintingPageBreaks method who gives incorrect area.
For example, the first page is supposed to be A1:C46 but that finds A1:C47. The second page is supposed to be A47:C92 and I got A48:C94.

I note that difference changes when I change margins.

files.zip (146.3 KB)

@ali10,

Thanks for your query.

This issue is already reported and logged in our database as follows:

CELLSNET-46257- Incorrect Print page breaks returned by Worksheet.GetPrintingPageBreaks()

Although as per our previous analysis, it is quite difficult to make this calculation exactly same as done by Excel. There is slight difference in calculations done by Aspose.Cells and Excel for calculating this page break but we will let you know if some more feedback is available.

@ali10,

During initial investigations, we have noticed cells A1:C47 for the print preview of first page in Microsoft Excel 2016. PrintPreview.png (94.0 KB)

Can you please share screenshot of print preview on your end as you have mentioned cells A1:C46 on first page.

Strange…
This is what I have for print preview in Mcrosoft Excel. PrintPreview.png (51.1 KB)

The first page is A1:C46.

@ali10,

Can you try to change the printer to “Microsoft Print to PDF” or “Microsoft XPS Document Writer” and then update us accordingly.

Yes that’s seems better PrintPreview2.png (48.8 KB)

But when I try with other document, I have problems again. MOCK_DATA.zip (57.4 KB)

It is C1:G48 on Excel and C1:G46 on Aspose.
I have not even the same number of page.
Excel : 21 pages
Aspose : 22 pages

Here a screenshot of the print preview PrintPreview3.png (35.6 KB)

@ali10,

Thank you for the feedback.

I have logged your comments under the same ticket. We will provide further feedback after analysis.

@ali10,

We have noticed that first page area is also C1:G48 by Aspose.Cells and the saved PDF file is also 21 pages. MOCK_DATA2_SavedByAspose.pdf (81.2 KB). It is same as the Excel print preview screenshot “PrintPreview3.png” shared by you.

Please try our latest version/fix: Aspose.Cells for .NET v18.8.3:

Let us know your feedback.

I tried with the lastest version.

That’s ok for the two first pages. And then problems come up.
Page 3:
Excel C97:G144
Aspose C97:G143

Page 4:
Excel C145:G192
Aspose C144:190

Page 5
Excel C193:G240
Aspose C191:G237

@ali10,

Thank you for your feedback. We have recorded it in our database for analysis.