Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JSpreadsheet
>
Tutorial
> Grouping
The following example shows you how to group rows.
import com.independentsoft.office.spreadsheet.Cell; import com.independentsoft.office.spreadsheet.CellType; import com.independentsoft.office.spreadsheet.Row; import com.independentsoft.office.spreadsheet.Workbook; import com.independentsoft.office.spreadsheet.Worksheet; public class Example { public static void main(String[] args) { try { Worksheet sheet1 = new Worksheet(); sheet1.setDefaultRowHeight(15); sheet1.setOutlineLevelRow(1); //grouping Row row1 = new Row(); Row row2 = new Row(); Row row3 = new Row(); row1.setOutlineLevel(1); //grouping row2.setOutlineLevel(1); //grouping row3.setOutlineLevel(1); //grouping Cell cell1 = new Cell(100); cell1.setType(CellType.NUMBER); Cell cell2 = new Cell(200); cell2.setType(CellType.NUMBER); Cell cell3 = new Cell(300); cell3.setType(CellType.NUMBER); row1.getCells().add(cell1); row1.getCells().add(cell2); row1.getCells().add(cell3); row2.getCells().add(cell1); row2.getCells().add(cell2); row2.getCells().add(cell3); row3.getCells().add(cell1); row3.getCells().add(cell2); row3.getCells().add(cell3); sheet1.getRows().add(row1); sheet1.getRows().add(row2); sheet1.getRows().add(row3); Workbook book = new Workbook(); book.getSheets().add(sheet1); book.save("c:\\test\\output.xlsx", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*