// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); worksheet.getRange("A2:A6").setNumberFormat("m/d/yyyy"); // Set data worksheet.getRange("A1:D6").setValue(new Object[][] { {null, "S1", "S2", "S3"}, {new GregorianCalendar(2015, 9, 7), 10, 25, 25}, {new GregorianCalendar(2015, 9, 24), 51, 36, 27}, {new GregorianCalendar(2015, 10, 8), 52, 85, 30}, {new GregorianCalendar(2015, 10, 25), 22, 65, 65}, {new GregorianCalendar(2015, 11, 10), 23, 69, 69} }); // Set columns width to display data worksheet.getColumns().get(0).autoFit(); // Add chart IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 250, 20, 360, 230); shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true); IAxis category_axis = shape.getChart().getAxes().item(AxisType.Category); // Config axis maximum and minimum scale // DateTime(2015, 12, 20) category_axis.setMaximumScale(DateInfo.ToOADate(new GregorianCalendar(2015, 11, 20))); // DateTime(2015, 10, 1) category_axis.setMinimumScale(DateInfo.ToOADate(new GregorianCalendar(2015, 9, 1))); // Config axis units category_axis.setBaseUnit(TimeUnit.Months); category_axis.setMajorUnitScale(TimeUnit.Months); category_axis.setMajorUnit(1); category_axis.setMinorUnitScale(TimeUnit.Days); category_axis.setMinorUnit(15); // Save to an excel file workbook.save("ConfigCategoryAxisUnits.xlsx");