pdfptable中的新行

我正在使用iText库在pdf文件中以表格格式打印某些数据。 我有11列,可以有多行。 为每列的标题创建标题后,如何在pdfptable中创建新行,以便我可以在单独的行上打印实际数据。

在PdfPTable的构造函数中,您可以指定行中的列数。

PdfPTable table = new PdfPTable(4) // 4 Columns PdfPCell cell; cell = new PdfPCell( new Phrase("Cell with colspan of 4") ) ; cell. setColspan(4) ; // an entire row anotherCell = new PdfPCell( new Phrase("Cell with colspan of 4") ); anotherCell.setColspan(4); // a second row 

如您所见,当您到达当前行中的colspan时,会创建一个新行。