// Create a new workbook Workbook workbook = new Workbook(); Object data = new Object[][] { {"Number", "Date", "Customer", "Description", "Trend", "0-30 Days", "30-60 Days", "60-90 Days", ">90 Days", "Amount"}, {"1001", new GregorianCalendar(2017, 4, 21), "Customer A", "Invoice 1001", null, 1200.15, 1916.18, 1105.23, 1806.53, null}, {"1002", new GregorianCalendar(2017, 2, 18), "Customer B", "Invoice 1002", null, 896.23, 1005.53, 1800.56, 1150.49, null}, {"1003", new GregorianCalendar(2017, 5, 15), "Customer C", "Invoice 1003", null, 827.63, 1009.23, 1869.23, 1002.56, null} }; IWorksheet worksheet = workbook.getWorksheets().get(0); worksheet.getRange("B2:K5").setValue(data); worksheet.getRange("B:K").setColumnWidth(15); worksheet.getTables().add(worksheet.getRange("B2:K5"), true); worksheet.getTables().get(0).getColumns().get(9).getDataBodyRange().setFormula("=SUM(Table1[@[0-30 Days]:[>90 Days]])"); //create a new group of sparklines. worksheet.getRange("F3:F5").getSparklineGroups().add(SparkType.Line, "G3:J5"); worksheet.getRange("G7:J7").setValue(new Object[]{new GregorianCalendar(2011, 11, 16), new GregorianCalendar(2011, 11, 17), new GregorianCalendar(2011, 11, 18), new GregorianCalendar(2011, 11, 19)}); worksheet.getRange("F3").getSparklineGroups().get(0).setDateRange("G7:J7"); worksheet.getRange("F3").getSparklineGroups().get(0).getAxes().getHorizontal().getAxis().setVisible(true); worksheet.getRange("F3").getSparklineGroups().get(0).getAxes().getHorizontal().getAxis().getColor().setColor(Color.GetGreen()); // Save to an excel file workbook.save("UseDateAxis.xlsx");
// Create a new workbook var workbook = Workbook() val data = arrayOf(arrayOf("Number", "Date", "Customer", "Description", "Trend", "0-30 Days", "30-60 Days", "60-90 Days", ">90 Days", "Amount"), arrayOf("1001", GregorianCalendar(2017, 4, 21), "Customer A", "Invoice 1001", null, 1200.15, 1916.18, 1105.23, 1806.53, null), arrayOf("1002", GregorianCalendar(2017, 2, 18), "Customer B", "Invoice 1002", null, 896.23, 1005.53, 1800.56, 1150.49, null), arrayOf("1003", GregorianCalendar(2017, 5, 15), "Customer C", "Invoice 1003", null, 827.63, 1009.23, 1869.23, 1002.56, null)) val worksheet = workbook.worksheets.get(0) worksheet.getRange("B2:K5").value = data worksheet.getRange("B:K").columnWidth = 15.0 worksheet.tables.add(worksheet.getRange("B2:K5"), true) worksheet.tables.get(0).columns.get(9).dataBodyRange.formula = "=SUM(Table1[@[0-30 Days]:[>90 Days]])" //create a new group of sparklines. worksheet.getRange("F3:F5").sparklineGroups.add(SparkType.Line, "G3:J5") worksheet.getRange("G7:J7").value = arrayOf(GregorianCalendar(2011, 11, 16), GregorianCalendar(2011, 11, 17), GregorianCalendar(2011, 11, 18), GregorianCalendar(2011, 11, 19)) worksheet.getRange("F3").sparklineGroups.get(0).dateRange = "G7:J7" worksheet.getRange("F3").sparklineGroups.get(0).axes.horizontal.axis.visible = true worksheet.getRange("F3").sparklineGroups.get(0).axes.horizontal.axis.color.color = Color.GetGreen() // Save to an excel file workbook.save("UseDateAxis.xlsx")