pdfptable中的新行 [英] A new row in pdfptable

查看:1095
本文介绍了pdfptable中的新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

推荐答案

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

In the constructor of PdfPTable you specify the number of columns in a row.

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时会创建一个新行当前行。

As you can see, a new row is created when you reach the colspan in the current row.

这篇关于pdfptable中的新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆