0
我創建了一個N列表使用setHeaderRows(N)表,當我添加到表N-1記錄和部署時,什麼都不顯示,即如果我創建一個表有5列標題,只需添加4個或更少的記錄到表中,不顯示任何內容。itext pdf不顯示錶時setHeaderRows
示例代碼
Document document = new Document(new Rectangle(605, 784), 28, 28, 42, 28);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("/temp/tabla.pdf"));
documento.open();
// Create table
PdfPTable tabla = new PdfPTable(5);
tabla.setComplete(false);
tabla.setWidthPercentage(100);
tabla.getDefaultCell().setBackgroundColor(BaseColor.WHITE);
tabla.setHeaderRows(5);
// Add Header Rows
for(int i=1; i<=5; i++)
{
celda = new PdfPCell();
Paragraph encabezado = new Paragraph("Header "+i);
celda.addElement(encabezado);
celda.setGrayFill(0.8f);
tabla.addCell(celda);
}
// Add some cells
for(int k=0; k<19; k++)
{
celda = new PdfPCell();
Paragraph contenido = new Paragraph("Cell "+k, helvetica11);
celda.addElement(contenido);
tabla.addCell(celda);
}
// In total add 4 rows
tabla.completeRow();
document.add(tabla);
document.close();
通常情況下,表格單元格是從SQL查詢,它可以返回一個或多個記錄填充數據,我都充滿了一個表「的」循環顯示故障。
有人可以幫助我如何解決這個問題?我應該設置什麼參數?或任何想法?
如果你看到在部分評論的代碼//添加一些細胞 - 添加一些細胞,但它是真的是唯一的演示表表中填充了來自sql查詢的數據 – TiPHeReTH 2014-09-23 16:04:39
代碼工作正常,同時行數add>≥5,但是任何sql查詢,在這種情況下得到的記錄數更少 – TiPHeReTH 2014-09-23 16:17:46
它只需要一行Header – TiPHeReTH 2014-09-23 18:24:04