Free Support Forum - aspose.com

Issue with Table header when exported as PDF

Hello Aspose Team,

When we tried to generate a PDF file through template/excel file, we faced an issue in the header of the table in the exported PDF. The header of the table that was expected to be displayed at the top of the page is instead being displayed in the middle of the table as seen in the screenshot.

Here is the sample Code

class Example {

    public static void main(String[] args) {
        FileInputStream io = new FileInputStream(new File("/home/asthapa/Pa-front/project/exportCheck/template1/fullTemplate.xlsx"));
        Workbook workbook = new Workbook(io);
        workbook.save("beforeCalculateFormula.pdf")
        workbook.calculateFormula();
        workbook.save("afterCalculateFormula.pdf")
    }

}

While further looking into this issue, we found out that this header issue is seen after execution of the workbook.calculateFormula()

Could you please look into this from your side? Please refer to the screenshots and sample template/Excel file.

issueScreenshot.png (26.5 KB)

fullTemplate.zip (204.7 KB)

@aasthapa,

Please try our latest version/fix: Aspose.Cells for Java v21.2.3 (attached).
aspose-cells-21.2.3.zip (7.1 MB)

I tested your scenario/ case using your sample code and template file with Aspose.Cells v21.2.3 and could not spot the issue. There are 294 pages in the output PDF and these look ok in the final output PDF. Could you try the suggested fix and if you still find the issue, kindly do provide details on which page or pages, you found your mentioned issues, you may also provide more comparison screenshots to highlight the issue. We will check your issue soon.

@Amjad_Sahi

This issue still replicates when I used the jar file that you provided (21.2.3) as well as the latest released aspose cell version (21.2).

When we directly save the template from Microsoft Excel in PDF format, the format is as expected i.e when the page breaks, the sub header i.e “Coverage Tier” is seen in the next page as the header. Please refer to this screenshot expectedPdf.png (22.7 KB) and the last table of page 7 and first table of page 8.
PDF file exported from excel: exportedFromExcel.pdf (1.8 MB)

But when the same template is exported as PDF through aspose, some tables are shifted randomly (refer to table with header “Division: Durham” (page 192)) which then causes the pages breaks to shift as well and the sub header is seen in the middle of the table like this Issue.png (64.4 KB)
PDF file: afterCalculateFormula.pdf (2.9 MB)

Note: Data in the later pdf file (afterCalculateFormula.pdf) is appearing from page 185. So please ignore all the other empty pages. This is expected.

Thanks,
Astha

@aasthapa,
We have observed the issue and logged it in our database for further investigation. You will be notified here once any update is ready for sharing.

This issue is logged as:
CELLSJAVA-43405 - Issue with table header while converting Excel file to PDF

@aasthapa,
We can see all the row height in sheet “Display” is custom, and row height is 14.45. To get more consistent output as Microsoft Excel, is it possible that set all the row height in sheet “Display” to a value of a multiple of 0.75(e.g. 14.25)?

We will check if it is possible to set all the row height in sheet “Display” to a value of a multiple of 0.75(e.g. 14.25).

However, by the phrase “To get more consistent output as Microsoft Excel” it seems that it will not completely resolve the problem in all cases. Could you please let us know whether setting all the row height in sheet “Display” to a value of a multiple of 0.75(e.g. 14.25) will resolve the issue in all cases? Or, is there some issue in Aspose itself which is being investigated on your end?

@rubyshrestha,
Thank you for the feedback. We have logged it with the ticket and will consider it while working on this issue.

@rubyshrestha,

It seems that while calculating page breaks, Microsoft Excel does some magic scale in horizontal and vertical direction especially when row height is not a value of a multiple of 0.75. Currently, we can handle most of cases while row height is a value of a multiple of 0.75. If you find any page breaks issue in this case, you can report it to us.