// Create a new workbook Workbook workbook = new Workbook(); InputStream fileStream = getResourceStream("xlsx\\SalesReport_sourcedata.xlsx"); workbook.open(fileStream); IWorksheet worksheet = workbook.getWorksheets().get(0); worksheet.getRange("G3").setValue("Product"); worksheet.getRange("H3").setValue("Sales"); worksheet.getRange("G3").getFont().setBold(true); worksheet.getRange("H3").getFont().setBold(true); worksheet.getRange("G4").setFormula2("=SORTBY(FILTER(B4:B13,E4:E13=1),FILTER(D4:D13,E4:E13=1),-1)"); worksheet.getRange("H4").setFormula2("=VLOOKUP(G4#,B4:D13,3,FALSE)"); workbook.getNames().add("Product", "=Sheet1!$G$4#"); workbook.getNames().add("Sales", "=Sheet1!$H$4#"); IShape chartShape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 700, 200, 500, 300); IChart chart = chartShape.getChart(); ISeries series = chart.getSeriesCollection().newSeries(); series.setFormula("=SERIES(\"Sales\", Product, Sales, 1)"); // Save to an excel file workbook.save("SalesReport.xlsx");