处理日历项目并使用 iText 生成 pdf 以打印约会。我可以绘制一个带有 colspan 的单元格和一个带有 rowpan 的单元格,但我不能将它组合起来。表格的宽度为 4 个单元格。我想实现这样的目标:
(A)(B)(C)(C)
(D)(E)(C)(C)
所以 (1,1), (1,2) 和 (2,1) (2,2) 是常规单元格。但是(1,3)中应该有一个单元格覆盖(1,3)(1,4)(2,3)和(2,4),因此colspan为2,rowspan为2。
当前代码:
PdfPTable 表 = 新 PdfPTable(4);
PdfPCell cell = new PdfPCell(new Phrase(" 1,1 "));
table.addCell(cell);
cell = new PdfPCell(new Phrase(" 1,2 "));
table.addCell(cell);
PdfPCell cell23 = new PdfPCell(new Phrase("multi 1,3 and 1,4"));
cell23.setColspan(2);
cell23.setRowspan(2);
table.addCell(cell23);
细胞 = 新 PdfPCell(新短语(“2,1”));
table.addCell(cell);
cell = new PdfPCell(new Phrase(" 2,2 "));
table.addCell(cell);
// 2,3 和 2,4 应该被填充,因为 1,3 有 rowspan 2 和 colspan 2。
//table.completeRow(); //没有效果
但是,这会产生错误:
ExceptionConverter: java.io.IOException: 文档没有页面。
如果我不开始创建第二行,它只会绘制得很好(1 行,并且 (1,3) 上的单元格的 colspan 为 2。由于没有第二行,rowspan(2) 没有效果。任何帮助表示赞赏。谢谢