[英]the Cell.add(“ Cell Content ”) does not work in Itext7 version 7.1.12 . is is this from me or from the Itext7 ? here are some codes
Cell SubTitle = new Cell().setBold();
Cell CA1Title = new Cell().setBold().setTextAlignment(TextAlignment.CENTER);
Cell CA2Title = new Cell().setBold().setTextAlignment(TextAlignment.CENTER);
Cell ExamTitle = new Cell().setBold().setTextAlignment(TextAlignment.CENTER);
Cell TotalTitle = new Cell().setBold().setTextAlignment(TextAlignment.CENTER);
Cell RemarkTitle = new Cell().setBold();
SubTitle.add("Subject");
CA1Title.add("1st C.A");
CA2Title.add("2nd C.A");
ExamTitle.add("Exam");
TotalTitle.add("Total Score");
RemarkTitle.add("Remark");
Cell.add()
方法不接受參數( String
)。
問題是什么?
在 iText 中,並非所有元素都可以只接受“簡單”文本——有些元素是其他“塊”元素的容器,而Text
是葉元素。 實際文本由Text
或Paragraph
類型的對象表示:
Text text1 = new Text("Text 1");
Paragraph p1 = new Paragraph(text1);
Paragraph p2 = new Paragraph("Text 2");
Cell
本身(如其文檔所述)只是一個包含其他元素的容器(並為表格提供跨行/列)。 所以要向它添加文本,你需要給它一個Paragraph
元素來保持:
Cell myCell = new Cell()
.add(new Paragraph("My Cell Title"))
.setBold()
.setTextAlignment(TextAlignment.CENTER);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.