java pdfptable 中的新行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4891578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
A new row in pdfptable
提问by yogsma
I am using iText library to print certain data in table format in a pdf file. I have 11 columns and can have multiple rows. After creating header for titles of each column, how do I create a new row in pdfptable so that I can print the real data on a separate row.
我正在使用 iText 库在 pdf 文件中以表格格式打印某些数据。我有 11 列,可以有多行。在为每列的标题创建标题后,如何在 pdfptable 中创建一个新行,以便我可以在单独的行上打印真实数据。
回答by dustyhoppe
In the constructor of PdfPTable you specify the number of columns in a row.
在 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
As you can see, a new row is created when you reach the colspan in the current row.
如您所见,当您到达当前行中的 colspan 时,会创建一个新行。