Issue With Aspose after generating PDF

Hello,

With the excel attached we are not getting chart when converted to PDF. Here is the code to generate PDF:

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{

// removeBlankRowsAndColumns(workbook.getWorksheets().get(j));
}
}

	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;
}

}

Please have a look.

Thanks,
Harish
new_imp.xlsx.zip (13.6 KB)

@HThagunna

Thanks for using Aspose APIs.

Please check your Excel file in Microsoft Excel Print Preview and you will see, your chart is missing there too. It is because the last sheet named Display has Print Area set to A1. Please delete it and your chart will render fine.

You can also delete it by the following code.

Java

//Remove the Print Area of this Worksheet
worksheet.getPageSetup().setPrintArea("");

Screenshot

Thank you @shakeel.faiz for replying.
Even after I cleared the print area, the chart is not present in the PDF. Please try it the attched file. This is the original file I am trying to convert to PDF with the same code posted by @HThagunna

Note: There are two charts in this updated file.

Issue: While converting to PDF, second chart (donut chart) goes missing.

Aspose_Cells_Clear_PrintArea.xlsx.zip (23.2 KB)

@girisagar46

Thanks for your posting and considering Aspose APIs.

We were able to observe this issue as shown in the following screenshot after converting your Excel file to Pdf and found, the second chart is missing.

This issue has been logged as

  • CELLSJAVA-42475 - Chart is missing in the output Pdf

Java

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

Download Link:
Output Pdf.zip (79.0 KB)

Screenshot

@girisagar46

Thanks for using Aspose APIs.

Please download and try the following fix and let us know your feedback.

Thank you.

This works perfectly. But, Aspose Cells 17.11.7 hasn’t been released in the Aspose maven artifactory.

@girisagar46

The next official release 17.12 which will also contain this fix will be released via Maven in next few days.

17.12
Here 17 means year 2017 and 12 means month December.

After this December, the official release of January will be 18.1.

18.1
Again, 18 means year 2018 and 1 means month January.

17.11.7 is actually a hot fix. It is not an official release. Hot fixes are provided to users via forums not via Maven.

Only official releases like 17.10, 17.11, 18.1, 18.2, 18.3 etc. are provided to users via Maven.

The issues you have found earlier (filed as CELLSJAVA-42475) have been fixed in newer version of Aspose.Cells for Java (Download | Maven).

Please also check the following document/blog for your reference: