//create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); IShape shape = worksheet.getShapes().addChart(ChartType.Line, 250, 20, 360, 230); worksheet.getRange("A1:D6").setValue(new Object[][]{ {null, "S1", "S2", "S3"}, {"Item1", 10, 25, 25}, {"Item2", -51, -36, 27}, {"Item3", 52, -85, -30}, {"Item4", 22, 65, 65}, {"Item5", 23, 69, 69} }); shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true); //config up down bars for line chart. shape.getChart().getLineGroups().get(0).setHasUpDownBars(true); shape.getChart().getLineGroups().get(0).getUpBars().getFormat().getFill().getColor().setRGB(Color.FromArgb(199, 235, 217)); shape.getChart().getLineGroups().get(0).getDownBars().getFormat().getFill().getColor().setRGB(Color.GetLightPink()); //save to an excel file workbook.save("CreateUpDownBars.xlsx");
//create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) val shape = worksheet.shapes.addChart(ChartType.Line, 250.0, 20.0, 360.0, 230.0) worksheet.getRange("A1:D6").value = arrayOf(arrayOf(null, "S1", "S2", "S3"), arrayOf("Item1", 10, 25, 25), arrayOf("Item2", -51, -36, 27), arrayOf("Item3", 52, -85, -30), arrayOf("Item4", 22, 65, 65), arrayOf("Item5", 23, 69, 69)) shape.chart.seriesCollection.add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true) //config up down bars for line chart. shape.chart.lineGroups.get(0).hasUpDownBars = true shape.chart.lineGroups.get(0).upBars.format.fill.color.rgb = Color.FromArgb(199, 235, 217) shape.chart.lineGroups.get(0).downBars.format.fill.color.rgb = Color.GetLightPink() //save to an excel file workbook.save("CreateUpDownBars.xlsx")