//create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); IShape shape = worksheet.getShapes().addChart(ChartType.XYScatterLines, 350, 20, 360, 230); worksheet.getRange("A1:B8").setValue(new Object[][]{ {75, 250}, {50, 125}, {25, 375}, {75, 250}, {50, 875}, {25, 625}, {75, 750}, {125, 500}, }); shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B8"), RowCol.Columns); shape.getChart().getChartTitle().setText("Scatter with Straight Lines and Markers Chart"); //save to an excel file workbook.save("XYScatterLinesChart.xlsx");
//create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) val shape = worksheet.shapes.addChart(ChartType.XYScatterLines, 350.0, 20.0, 360.0, 230.0) worksheet.getRange("A1:B8").value = arrayOf(arrayOf(75, 250), arrayOf(50, 125), arrayOf(25, 375), arrayOf(75, 250), arrayOf(50, 875), arrayOf(25, 625), arrayOf(75, 750), arrayOf(125, 500)) shape.chart.seriesCollection.add(worksheet.getRange("A1:B8"), RowCol.Columns) shape.chart.chartTitle.text = "Scatter with Straight Lines and Markers Chart" //save to an excel file workbook.save("XYScatterLinesChart.xlsx")