Reputation: 711
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
Upvotes: 0
Views: 395
Reputation: 1725
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");
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.
Note: I am working as Developer Evangelist at Aspose
Upvotes: 1