Aspect ratio is not maintained in PNG output of Excel chart in Java

Hi,

I am using Aspose cells v8.6.3.2

On converting Chart 1 to PNG the aspect ratio is not preserved, initial chart size is 5X3 inches but in PNG, the size is 3007 X 1869 pixels (3/5 = 0.6 and 1869/3007 = 0.62).

For reference, sample code & documents attached.

Sample Code:
Workbook workbook = new Workbook(“Excel.xlsx”);

WorksheetCollection ws = workbook.getWorksheets();

String worksheetName = “Aspect ratio”;

Chart chart = ws.get(worksheetName).getCharts().get(“Chart 1”);

chart.toImage(“D:\response_8.6.3.2.pdf”);


Can you please analyse this issue.

Thanks
Neha

Hi,

Thanks for your posting and using Aspose.Cells.

Please download and use the latest version: Aspose.Cells
for Java v8.6.3.4
it works fine and gives correct aspect ratio. Let us know your feedback.

Hello,


Thanks for your reply.

I tested this issue using Aspose.Cells v8.6.3.4. Unfortunately, the issue still exists although it has improved a little. Initial chart size is 5X3 inches but in PNG, the size is 3007 X 1807 pixels (3/5 = 0.6 and 1807/3007 = 0.60093116).

For reference, I have attached the PNG generated using Aspose.Cells v8.6.3.4.
Can you please analyse this issue.

Thanks
Neha

Hi Neha,

Thanks for your nice sharp analysis and using Aspose.Cells.

I have looked into this issue further and found that it is not possible to do everything perfectly. I have tested it with Microsoft Excel. I saved your source excel file into HTML using Microsoft Excel 2010 and checked the chart images. These images were

752x452 = 0.6026
482x289 = 0.5995

I have attached the images for your reference. So this is not a bug and we are afraid, it cannot be improved further.