// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); // Add columnClustered chart IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 250, 20, 360, 230); // Set data for the chart worksheet.getRange("A1:D6").setValue(new Object[][]{ {null, "S1", "S2", "S3"}, {"Item1", 10, 25, 25}, {"Item2", -51, 36, 27}, {"Item3", 52, 50, -30}, {"Item4", 22, 65, 30}, {"Item5", 23, 40, 69} }); // Set series data shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true); // Set plot area's format IPlotArea plotarea = shape.getChart().getPlotArea(); plotarea.getFormat().getFill().getColor().setRGB(Color.GetLightGray()); plotarea.getFormat().getLine().getColor().setRGB(Color.GetGray()); plotarea.getFormat().getLine().setWeight(1); // Save to an excel file workbook.save("ConfigPlotAreaFormat.xlsx");
// Create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) // Add columnClustered chart val shape = worksheet.shapes.addChart(ChartType.ColumnClustered, 250.0, 20.0, 360.0, 230.0) // Set data for the chart worksheet.getRange("A1:D6").value = arrayOf( arrayOf(null, "S1", "S2", "S3"), arrayOf("Item1", 10, 25, 25), arrayOf("Item2", -51, 36, 27), arrayOf("Item3", 52, 50, -30), arrayOf("Item4", 22, 65, 30), arrayOf("Item5", 23, 40, 69) ) // Set series data shape.chart.seriesCollection.add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true) // Set plot area's format val plotarea = shape.chart.plotArea plotarea.format.fill.color.rgb = Color.GetLightGray() plotarea.format.line.color.rgb = Color.GetGray() plotarea.format.line.weight = 1.0 // Save to an excel file workbook.save("ConfigPlotAreaFormat.xlsx")