// Create a new workbook Workbook workbook = new Workbook(); IWorksheet ws = workbook.getWorksheets().get(0); ws.setName("SEQUENCE"); ws.getRange("$B$1").setValue( "The SEQUENCE function allows you to generate a list of sequential numbers in an array. Syntax: SEQUENCE(rows,[columns],[start],[step])"); ws.getRange("$C$3").setValue("SEQUENCE(4,5)"); ws.getRange("$C$11:$C$12").setValue(new Object[][] { { "SEQUENCE(15,,TODAY()) with d-mmm-yy" }, { "Date" } }); ws.getRange("$H$11:$H$12").setValue(new Object[][] { { "SEQUENCE(10,,100,-10)" }, { "Number" } }); // Apply table style. ITable table = ws.getTables().add(ws.getRange("C12:C27"),true); ITable table1 = ws.getTables().add(ws.getRange("H12:H22"),true); table.convertToRange(); table1.convertToRange(); ws.getRange("$C$4").setFormula2("=SEQUENCE(4,5)"); ws.getRange("$C$13").setFormula2("=SEQUENCE(15,,TODAY())"); ws.getRange("$H$13").setFormula2("=SEQUENCE(10,,100,-10)"); ws.getRange("$C$13:$C$27").setNumberFormat("d-mmm-yy"); ws.getRange("C:C").getEntireColumn() .setColumnWidth(ws.getRange("C:C").getEntireColumn().getColumnWidth() * 1.5); // Save to an excel file workbook.save("SequenceFunction.xlsx");