Hello,
When trying to convert a chart which has an image inside of it, to an image using .toImage method, the image inside of the chart gets distorted and doesn’t match the original chart.
Here’s a simple code snippet I’m using to convert the excel chart to a png image:
Generated image doesn’t match original chart from excel.
I’ve attached the excel file with the chart and the generated image. ChartToImage.zip (69.5 KB)
Which version are you using ? Please try the latest version 25.1.
And we added an issue CELLSJAVA-46242 in our internal tracing system for this issue. We will check it soon.
Hi @dfinsolutions
We investigated this issue, and the output results are as follows, and no obvious distortion was found. (I have tested it under Aspose.Cells for .net and Java.)
Since you provided Java code, the following image is the output I got using Aspose.Cells for Java 25.1. 250121.png (42.7 KB)
Would you please confirm the following information:
1, The version of Aspose.Cells you are using (.net, net6, or Java, JDK version) and the runtime environment(windows or linux, skiasharp or system.drawing.common).
2, Have you made additional settings for the environment’s DPI.
3, Please try the following code and let us know your feedback, thank you.
String path = "";
Workbook book = new Workbook(path + "Book1.xlsx");
Chart chart = book.getWorksheets().get(0).getCharts().get(0);
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageType(ImageType.PNG);
options.setVerticalResolution(96);
options.setHorizontalResolution(96);
chart.toImage(path + "out_java.png", options);
Using Aspose.Cells 25.1 for Java and your given code snipped I still get distorted results.
I’ve attached an image of how the original chart looks inside of excel and how exported image looks. image.png (96.3 KB)
Hi @dfinsolutions
Please take a look at the situation presented in the picture I sent, in Excel.
The green and red horizontal bars are pushed down a distance (in my excel). This is the reason why it goes out of the circle.
It seems that different versions of Excel display this situation (shape placed inside the chart) differently.
Can you confirm your Excel version and the environment you are using? Thank you.
Hi @dfinsolutions
For this issue, we conducted more research. We noticed that the “workbook.DefaultStyle.Font” setting in the Excel file you provided is set to “Aptos Narrow”.
Please confirm that the “Aptos Narrow” font is correctly installed in your MAC environment. If the font is missing, the column width may change resulting in the shape being stretched horizontally.
Attached is a file for your reference after we changed the default font to “Arial”. You can also use it for observation and testing.
Please let us your feedback, thank you. Book1_Arial.zip (41.6 KB)
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.