我正在使用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
Run Code Online (Sandbox Code Playgroud)
如您所见,当您到达当前行的colspan时,会创建一个新行。
| 归档时间: |
|
| 查看次数: |
12972 次 |
| 最近记录: |