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

Free Support Forum - aspose.com

How to set the Interval unit in a chart?


I have a chart in my Excel file where the X axis is a set of dates. As I have many values, the axis labels are sometimes hardly legible (see 1-before.jpg).
In Excel 2007, I can change the “Interval Unit” (see 2-menu.jpg and 3-option.jpg) to 7 (for example), to make this chart more readable (see 4-after.jpg).

My question is how can I set this option using Aspose Cells (v2.5.4.1) ? I didn’t find anything in the chart.getCategoryAxis() object…



Thanks for your interest in Aspose.Cells for Java and the screenshots.

Can you please also attach the sample xls/xlsx file, which you can create manually using Ms-Excel, with such a chart? It will help us find the Aspose.Cells solution.


Here is a simple exemple to illustrate my question.
I generate an XLSX file, using the following code:

Workbook workbook = new Workbook();
Worksheet ws = workbook.getWorksheets().getSheet(0);
Cells cells = ws.getCells();
for (int i = 1; i < 100; i++) {
cells.getCell(“A” + i).setValue(i);
cells.getCell(“B” + i).setValue(i);
Chart chart = ws.getCharts().addChart(ChartType.LINE, 5, 1, 20, 10);
chart.getNSeries().add(“A1:B99”, true);
workbook.save(“c:\test.xlsx”, FileFormatType.XLSX);

Please find the generated Excel sheet, as well as the modified one, with the adequate option filled.



Thanks for your sample files.
Please find below the source code to specify the interval unit for axis of a chart. Also, attached is my output file. I have tested this code with latest release of Aspose.Cells JAVA v2.5.4.


Workbook wb = new Workbook();
Chart chart = wb.getWorksheets().getSheet(0).getCharts().getChart(0);
//Specify Axis Interval Unit

Thanks, it answers my question!