0

I have an excel file which has two charts (Bar of pie and Donut Chart). These charts are created through cell reference from other sheets. But, when I am saving the file to PDF, second chart (donut chart) is not rendered in the pdf.

Here's the sample code in Java for Aspose Cells.

import com.aspose.cells.*

class AsposeCellTesting {

public static void main(String[] args) {
    generatePDF()
}

public static void generatePDF(){
    Workbook workbook = new Workbook(new FileInputStream(new File("new_imp.xlsx")));
    println "Number of sheets = ${workbook.getWorksheets().getCount()}"

    for (int j = 0; j < workbook.getWorksheets().getCount(); j++) {
        if(shouldExclude(workbook.getWorksheets().get(j).getName())){
            workbook.getWorksheets().get(j).setVisible(false);
        }else{
            // do nothing
        }
    }

    workbook.calculateFormula();
    workbook.save("DONUT_CHART.pdf");
}

public static Boolean shouldExclude(String sheetName) {
    if(sheetName.startsWith("_") || sheetName.contains("staging") ||sheetName.contains("Staging"))  {
        return true;
    }
    return false;
  }

}

If all data for Donut Chart is available (i.e. 2.0% instead of 0.0%) in the data, the export works fine.

Aspose Cells version : aspose-cells:17.4.0

Excel file can be downloaded here: https://drive.google.com/file/d/1UgFVTAOk3NcvQNdbjWBlf3zTudxjOmTj/view?usp=sharing

1
  • FYI: Please check the update in the answer with screenshot. This issue is now fixed in Aspose.Cells 17.12. Thank you. Commented Dec 19, 2017 at 12:57

1 Answer 1

1

We have tested your Excel file with the most recent version i.e. 17.11.3 and found that this issue is occurring because of some bug in Aspose.Cells. We have logged this issue in our database for investigation and for a fix. Once, the issue is resolved, we will update you. Here is the sample code used to test this issue and the screenshot of Pdf created by Microsoft Excel and Pdf created by Aspose.Cells for a reference.

Java

Workbook wb = new Workbook(dirPath + "Aspose_Cells_Clear_PrintArea.xlsx");
wb.save(dirPath + "output.pdf");

Screenshot enter image description here

Update-1

This issue has been fixed in the Aspose.Cells for Java 17.12. Here is the output Pdf screenshot generated with the fixed version for a reference.

enter image description here

Note: I am working as Developer Evangelist at Aspose

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.