//create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); IShape shape = worksheet.getShapes().addChart(ChartType.ColumnStacked, 250, 20, 360, 230); worksheet.getRange("A1:C6").setValue(new Object[][]{ {103, 121, 109}, {56, 94, 115}, {116, 89, 99}, {55, 93, 70}, {114, 114, 83}, {125, 138, 136} }); shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:C6"), RowCol.Columns); shape.getChart().getChartTitle().setText("Column Stacked Chart"); //save to an excel file workbook.save("ColumnStackedChart.xlsx");
//create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) val shape = worksheet.shapes.addChart(ChartType.ColumnStacked, 250.0, 20.0, 360.0, 230.0) worksheet.getRange("A1:C6").value = arrayOf(arrayOf(103, 121, 109), arrayOf(56, 94, 115), arrayOf(116, 89, 99), arrayOf(55, 93, 70), arrayOf(114, 114, 83), arrayOf(125, 138, 136)) shape.chart.seriesCollection.add(worksheet.getRange("A1:C6"), RowCol.Columns) shape.chart.chartTitle.text = "Column Stacked Chart" //save to an excel file workbook.save("ColumnStackedChart.xlsx")