Page Numbering of Excel files with multiple worksheets(ECDCTS-10372)

@rnara ,

The actual page count is 98. Please check the pdf file generated by Excel on our side:
TEST page numbering IMM 2000 - kate_SavedByExcel.pdf (4.0 MB)

For the issue that Excel generates 98 pages, but Aspose.Cells generates 99 pages, the reason is that the cached row height in the source file for the rows that are auto-height is not right, Excel re-calculated these row height. However, Aspose.Cells uses the cached value directly by default. Use Worksheet.autofitRows(true) can re-calculate these values, however we can’t get the same value as Excel for some rows. So, we can’t get the same page count as Excel in this case.

So, what is the expected row height? Is there any way to set it manually in excel? If so how ?
Thanks!

@rnara
Using Worksheet.autofitRows(true) can achieve the expected row heights.

In Excel, you can manually set the row height using the following steps:

  1. Select the Row(s): Choose the row or rows for which you want to adjust the height.
  2. Right-Click on the Selected Row(s): Right-click on the selected row(s).
  3. Choose “Row Height” Option: From the context menu that appears, choose the “Row Height” option.
  4. Enter Row Height Value: In the dialog box that pops up, enter the desired row height value in points. Then click “OK.”

This way, you manually set the row height for the selected row(s). Keep in mind that manually setting the row height will override any automatic row height adjustments.

(workbook.getWorksheets().get(3).getCells().getRowHeight(rowIndex) )
So what are we expecting as rowIndex here?
So how is it possible to print the height of each and every row from a worksheet?
What is expected row height to be worked as Aspose?

We are looking for a workaround which doesn’t require any code change. Please let me know if I can manually adjust the row height likewise we manually set 600 dpi earlier and so that giving Aspose rendition it generates 114pages.

Thanks

wb.getWorksheets().get(i).getPageSetup().setPrintQuality(600);
Does this above code set the printQuality of the worksheet only or adjust the row height also?
How come setting manually to 600dpi impact on row height? I haven’t changed anything to row height.
In my case, I have just adjusted the print quality to 600dpi from 1200dpi for each worksheet and gave rendition using Aspose.

@rnara
About the expected row height, you can refer to the docs.

If you set a fixed row height, it’s also challenging to match the number of printed pages in Excel.

Additionally, setPrintQuality only impacts the page layout/break and has no direct relationship with row height.

Regarding your question, we need some time to consider whether there is a better solution. Thank you!

@rnara
For the rows that are auto height,Excel will automatically re-calculate row height for them when open source file in Excel.
So, you can just only open the source file in Excel,then save the source file. Note, these operators need to be done on Windows with system display setting set to 100%.

Is it possible to fix this issue as well as Aspose is not working as expected(as excel)? Instead using cached value, can Aspose considering re-calculated the row height and generate the same page count as Excel?
Thanks,
Bhupali

@rnara
Thank you for your feedback. Let us investigate and analyze your issue in details. Once we have an update on it, we will let you know.

@rnara ,

Worksheet.autoFitRows(true); can re-calculate the height of rows that are auto-height. However, sometimes, Aspose.Cells calculates the different value comparing with the one calculated by Excel.

So, we can’t fix the issue.

The issues you have found earlier (filed as CELLSJAVA-45829) have been fixed in Aspose.Cells for Java 24.2.

Why is it that Aspose.cells can’t calculate the exact same row height as Excel? We expect Aspose function as accurately as Excel and we can’t agree on to this bug. Please address this issue.

Also, may I know when this bug CELLSJAVA-45829 is fixed? Which version of Aspose?
Thanks,
Bhupali

@rnara
CELLSJAVA-45829 has been fixed in Aspose.Cells for Java 24.2. We will further investigate the errors in row height calculation compared to Excel. Hopefully we could figure it out soon. Once we have an update on it, we will let you know.

@rnara
As you may have known(such as those discussions in this post), the visual effect is influenced by many factors, such as fonts, resolution, scaling, and so on. We always try our best to achieve the same effect as Excel. However, not all patterns that ms excel uses are easy to find and follow. Sometimes Excel uses some magical tricks that we can’t even guess. So we are afraid not all such kind of issues can be solved immediately.

On the other hand, when we said it cannot be fixed, it mainly refers to automatically calculating row height like Excel does. For most template files, they are generated by ms excel and the row height values saved in it are just the correct ones. One reason that we do not re-calculate the row height automatically is that for few special cases we cannot get the correct result same with ms excel, the re-calculation of row height may make the output result wrong from right. Another more important reason is, as a library for program interfaces, performance is a factor that we must consider with higher priority. Calculating row height is a time-consuming process. If we make it as automatic operation, all users will be forced to accept the time cost. But for most of template files and most users, it is unnecessary. So, we do not do it automatically, instead for those template files which need this operation, user may call autoFitRows() manually.

For your case, if calling autoFitRows() may produce better result for most of those template files, we think you may add this invocation in your program as an unified operation. If you find those cases that this invocation gives incorrect result, it is always appreciated if you can provide the sample file and code so we can try to figure the issue out and try to improve our component. However, as we have said, it is hard for us to solve all of them. Anyways, we will try our best. Thank you for your understanding.

Yes, autoFitRows() gives different output than Excel. I have attached an excel and Aspose(adding autoFitRows(true)) generates 99pages whereas Excel produces 91pages
TEST page numbering IMM 2000 - kate.zip (4.0 MB)
Please let us know the fix for it. Thanks!

@rnara
Thanks for further details. Let us investigate and analyze your issue in details. Hopefully we could figure it out soon. Once we have an update on it, we will let you know.

@rnara

Actually Excel generates 98 pages. Aspose.Cells generates 99 pages without autoFitRows(true), and Aspose.Cells generates 95 pages with autoFitRows(true) in Aspose.Cells for Java 24.2.
There are too many factors that we can’t do exactly same as Excel. Take Row 24 and Row 1012 in sheet “Immulite 2000 DMR” for example, there are only one line text for the two rows, and the cached row heights(auto-height) are both 25.5. However, Excel only recalculates the row height for Row 1012, but keeps the origin value for Row 24…

  1. Is it a limitation on Aspose’s side that it’s not aligning with the Excel output?
  2. Why is it not possible to implement alingning with Excel?
  3. Additionally, how can I differentiate between the files that will work and those that won’t? I need to know the exact reason. Plese justify. Thanks!

@rnara,

  1. You can say that, but it is true only for certain cases. Sometimes it is impossible to replicate MS Excel’s rendering results. There is only a one-page difference on our side.

  2. As we mentioned before, there are many factors that can cause the rendering to not match exactly with MS Excel. We retrieve cached row heights from the source XLSX file. In some cases, like yours, MS Excel picks and recalculates certain row heights, but not all, which can result in slightly different outcomes.

  3. It is difficult to distinguish these differences. In most cases, Aspose.Cells mimics MS Excel for rendering, but in rare cases, like yours, discrepancies may occur.