Excel to PDF - Reason about difference in number of pages after rendering

Hi,
I am using aspose cells for xsl to PDF.
Issue 1:- In the print preview of office, only 6 sheets are visible, but Aspose rendering all of the sheets.

Issue 2:- Even when I set visible as false for the sheets that are not selected, it renders all.

Issue 3: the select logic itself is giving incorrect answers for this input.

Sample Code:-

public static void main(String args[]) throws Exception {
loadLicense();

Workbook workbook = new Workbook(“C:\Users\avashish\Downloads\ECDCTS-5740\test.xls”);
com.aspose.cells.PdfSaveOptions options = new com.aspose.cells.PdfSaveOptions();
Worksheet worksheet = null;
System.out.println("total number of pages "+workbook.getWorksheets().getCount());
for (int i = 0; i < workbook.getWorksheets().getCount(); i++)
{
if (workbook.getWorksheets().get(i).isSelected()) {
System.out.println("Selected page number "+ i);
workbook.getWorksheets().get(i).setVisible(true);
System.out.println("visibility chage done for page number " + i);
}
workbook.getWorksheets().get(i).setVisible(true);
System.out.println("Not Selected this page "+i);
}
workbook.save(“C:\Users\avashish\Downloads\ECDCTS-5740\excel_.pdf”, options);

Attaching the input here.
Aspose.zip (2.1 MB)

@AjeshEMC,

Thanks for your query.

Following is our response to your issues:

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-42779 - Extra pages rendered to PDF

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-42780 - WorkSheet.setVisible() not working fine

I am afraid I could not reproduce this issue as during testing isSelected() function is working fine. Please share your console application (runnable) for this issue. We will investigate it and provide our feedback after testing.

@AjeshEMC,

We have investigated Issue 2 stated below:

This does not seem to be an issue as when we render first visible sheet to PDF using Excel, it also renders 6 pages to PDF. So it does not seem to be an issue. If you still face some issue, please provide your console application (runnable) for our analysis along with the output created by Excel. We will analyze the information and provide our feedback

So you are able to reproduce this issue. Has this been logged as a defect?

Can you explain it with aspose rendered pdf.
Please provide the rendition along with the sample code.
And what all issues have you been able to reproduce.

Regards,
Ankur

@AjeshEMC,

For Issue 1: In the print preview of MS Office, only 6 sheets are visible, but Aspose is rendering all of the sheets. "By default, Microsoft Excel only prints active/selected sheets (it is the first sheet for your file, sheet index is 0) in the PrintPreview (see screenshot “PrintActiveSheets.png”), you can see there are 6 pages. But if you change to print “Print Entire Workbook” (see screenshot “PrintEntireWorkbook.png”), you will see there are 1101 pages. Our Workbook.Save API will save all visible sheets to PDF, same as “Print Entire Workbook” in Microsoft Excel. So this is not an issue.

For Issue 2: Even when I set visible as false for the sheets that are not selected, it renders all. It is because your code is using different logic. Please use the following code, it will save the selected sheets to PDF (see attachment “output.pdf”).

Workbook workbook = new Workbook(srcFile);
com.aspose.cells.PdfSaveOptions options = new com.aspose.cells.PdfSaveOptions();
System.out.println("total number of sheets "+workbook.getWorksheets().getCount());
for (int i = 0; i < workbook.getWorksheets().getCount(); i++)
    {
        if (workbook.getWorksheets().get(i).isSelected())
        {
            System.out.println("Selected sheet index "+ i);workbook.getWorksheets().get(i).setVisible(true);
            System.out.println("visibility change done for sheet index " + i);
        }
        else
        {
            workbook.getWorksheets().get(i).setVisible(false);
            System.out.println("Not Selected this sheet "+i);
        }
   } 
workbook.save(output.pdf, options);

For Issue 3: The select logic itself is giving incorrect answers for this input.

attachment.zip (378.3 KB)

Let us know your feedback.