rk: You MUST know the number of columns when constructing a Table. // The number of rows is not important.
Table table = new Table(3); table.setBorderWidth(1); table.setBorderColor(new Color(0, 0, 255)); table.setPadding(5); table.setSpacing(5); Cell cell = new Cell("header"); cell.setHeader(true); cell.setColspan(3);
table.addCell(cell); table.endHeaders(); cell = new Cell("example cell with colspan 1 and rowspan 2"); cell.setRowspan(2); cell.setBorderColor(new Color(255, 0, 0));
table.addCell(cell); table.addCell("1.1"); table.addCell("2.1"); table.addCell("1.2"); table.addCell("2.2"); table.addCell("cell test1"); cell = new Cell("big cell"); cell.setRowspan(2); cell.setColspan(2);
table.addCell(cell); table.addCell("cell test2"); The result of this code is a table:
header |
example cell with colspan 1 and rowspan 2 | 1.1 | 2.1 |
1.2 | 2.2 |
cell test1 | big cell |
cell test2 |
@see Rectangle
@see Element
@see Row
@see Cell