We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Chart X-Axis Labels are Vertical Instead of Diagonal when Converted to Image


We are seeing an issue where the labels on the a Chart’s horizontal axis (aka X-axis) are appearing vertically instead of diagonally. If you open the attached WaterfallChart.xlsx file in Excel, you should see that the X-axis labels have diagonal orientation. However, when Aspose Cells converts the Chart to an image, it shows the X-axis labels with a vertical orientation. Our expectation is that the the X-axis labels in the Aspose generated image appear diagonally (similar to Excel).

This behavior can be seen in the latest Aspose Cells for Java version 20.9, the attached WaterfallChart.xlsx workbook and the following Java code:

final String xlFile = [PATH] + "WaterfallChart.xlsx";
Workbook wb = new Workbook(xlFile);
Shape chart = wb.getWorksheets().get("Sheet1").getShapes().get("Chart 1);

// Convert the Chart to PNG Image
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setDesiredSize(chart.getWidth(), chart.getHeight());

ByteArrayOutputStream baos = new ByteArrayOutputStream();
chart.toImage(baos, options);
byte[] imgBytes = baos.toByteArray();

// Save the image file
Path imgFile = Paths.get(xlFile.replace(".xlsx", ".png"));
Files.write(imgFile, imgBytes);
System.out.format("Saved image as: %s%n", imgFile.toString());

Running the above code should produce a new WaterfallChart.png file similar to the one attached. Rendering the PNG shows the X-axis labels with horizontal orientation. Additionally, notice how the chart area is much smaller (compared to Excel) - because the X-axis labels are taking up much more of the available vertical space.

Environment Details:

  • Aspose Cells for Java 20.9
  • Java version 1.8.0_211
  • Windows 10 OS (but also reproducible under Linux).

File description from the VerticalChartLabels.zip (17.2 KB) attachment:

  • WaterfallChart.png: PNG file generated by the code above on our environment.
  • WaterfallChart.xlsx: Workbook containing the source chart that is converted to a PNG image per the code above.

Thank you!

We have logged the issue as “CELLSJAVA-43311” in our database for investigations. Once we will have some news for you, we will update you in this topic.

This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

The issues you have found earlier (filed as CELLSJAVA-43311) have been fixed in Aspose.Cells for Java 20.10. This message was posted using Bugs notification tool by ahsaniqbalsidiqui

Thank you Ahsan!
We’ve tested the fix with Aspose Cells 20.10, the chart looks very good :smiley:


Good to know that your issue is resolved by the new version. In the event of further queries or issue, feel free to write us back.