//create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); IShape shape = worksheet.getShapes().addChart(ChartType.BarStacked100, 250, 20, 360, 230); worksheet.getRange("A1:B5").setValue(new Object[][]{ {1, 5}, {2, 4}, {3, 3}, {4, 2}, {4, 1} }); shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B5"), RowCol.Columns); shape.getChart().getChartTitle().setText("Bar Stacked 100 Chart"); shape.getChart().getLegend().setPosition(LegendPosition.Left); //save to an excel file workbook.save("BarStacked100Chart.xlsx");
//create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) val shape = worksheet.shapes.addChart(ChartType.BarStacked100, 250.0, 20.0, 360.0, 230.0) worksheet.getRange("A1:B5").value = arrayOf(arrayOf(1, 5), arrayOf(2, 4), arrayOf(3, 3), arrayOf(4, 2), arrayOf(4, 1)) shape.chart.seriesCollection.add(worksheet.getRange("A1:B5"), RowCol.Columns) shape.chart.chartTitle.text = "Bar Stacked 100 Chart" shape.chart.legend.position = LegendPosition.Left //save to an excel file workbook.save("BarStacked100Chart.xlsx")