// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); worksheet.getRange("A1:B11").setValue(new Object[][]{ {"Complaint", "Count"}, {"Too noisy", 27}, {"Overpriced", 789}, {"Food is tasteless", 65}, {"Food is not fresh", 9}, {"Food is too salty", 15}, {"Not clean", 30}, {"Unfriendly staff", 12}, {"Wait time", 109}, { "No atmosphere", 45}, {"Small portions", 621 } }); worksheet.getRange("A:A").getColumns().autoFit(); //Create a pareto chart. IShape shape = worksheet.getShapes().addChart(ChartType.Pareto, 300, 20, 300, 200); shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:B11")); //Sets bins type by size. shape.getChart().getChartGroups().get(0).setBinsType(BinsType.BinsTypeBinSize); shape.getChart().getChartGroups().get(0).setBinWidthValue(300); //Set underflow bin value. shape.getChart().getChartGroups().get(0).setBinsUnderflowEnabled(true); shape.getChart().getChartGroups().get(0).setBinsOverflowValue(50); // Save to an excel file workbook.save("AddParetoChart.xlsx");
// Create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) worksheet.getRange("A1:B11").setValue(arrayOf(arrayOf("Complaint", "Count"), arrayOf("Too noisy", 27), arrayOf("Overpriced", 789), arrayOf("Food is tasteless", 65), arrayOf("Food is not fresh", 9), arrayOf("Food is too salty", 15), arrayOf("Not clean", 30), arrayOf("Unfriendly staff", 12), arrayOf("Wait time", 109), arrayOf("No atmosphere", 45), arrayOf("Small portions", 621))) worksheet.getRange("A:A").columns.autoFit() //Create a pareto chart. val shape = worksheet.shapes.addChart(ChartType.Pareto, 300.0, 20.0, 300.0, 200.0) shape.chart.seriesCollection.add(worksheet.getRange("A1:B11")) //Sets bins type by size. shape.chart.chartGroups.get(0).binsType = BinsType.BinsTypeBinSize shape.chart.chartGroups.get(0).binWidthValue = 300.0 //Set underflow bin value. shape.chart.chartGroups.get(0).binsUnderflowEnabled = true shape.chart.chartGroups.get(0).binsOverflowValue = 50.0 // Save to an excel file workbook.save("AddParetoChart.xlsx")