I'm new to itext 7. So I'm trying to get the hang of making tables but for reason, the cells only seem to be stacked to each other. How do I create a new column?
Table table1 = new Table(5); // 3 columns.
table1.addCell("test");
table1.addCell("test");
table1.addCell("test");
I keep getting this kind of design, no matter how many combinations or new Cells I've tried. I wanted to have 3 columns instead of 3 rows on one column.
I think you are confounding rows and columns. First you are creating a Table with 5 Columns.
Table table1 = new Table(5);
Whenever you add a cell it will be added as a new column. When you added 5 Columns and add another one, then the new one will create a new row.
table1.addCell("test");
table1.addCell("test");
table1.addCell("test");
table1.addCell("test");
table1.addCell("test");
table1.addCell("test"); // this one will be added in a new row
Note that incomplete rows aren't added by default, unless you ask iText to complete the rows (see Why is content missing in my table?).
If you want to span one cell over more than one row or column you can set the rowspan or columnspan of the cell. See the Colspan and rowspan examples on the official web site.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments