【发布时间】:2020-05-19 04:01:38
【问题描述】:
。在第 3 行第 6 列(标题)中,我创建了一个列,其中序列号(第 4 行,单元格 12)需要从 1 填充到它有多少条记录。我搜索了它是如何工作的,但我不知道它是如何完成的。有人可以帮忙吗?
Row<PDPage> row3 = table.createRow(20.0f);
Cell<PDPage> cell6 = row3.createCell(10.0f, "SL NO");
Cell<PDPage> cell7 = row3.createCell(10.0f, "Name");
Cell<PDPage> cell8 = row3.createCell(15.0f, "Age");
Cell<PDPage> cell9 = row3.createCell(35.0f, "Number:");
Cell<PDPage> cell10 = row3.createCell(15.0f, "Address:");
Cell<PDPage> cell11 = row3.createCell(15.0f, "PIn:");
int a=0;
int b=++a;
for(int i=0;i<Recordss.size();i++) {
Record temp = (Record) Recordss.get(i);
Row<PDPage> row4 = table.createRow(100.0f);
Cell<PDPage> cell12 = row4.createCell(10.0f, String.valueOf(b));
Cell<PDPage> cell13 = row4.createCell(10.0f, temp.getName());
Cell<PDPage> cell14 = row4.createCell(15.0f, temp.getAge());
Cell<PDPage> cell15 = row4.createCell(35.0f, temp.getNumber());
Cell<PDPage> cell16 = row4.createCell(15.0f, temp.getAddress());
Cell<PDPage> cell17 = row4.createCell(15.0f, temp.getPin());}
【问题讨论】:
-
您是否尝试过使用计数器变量并将其每行加 1?
-
谢谢,但显示的所有记录只有数字 1 重复。我编辑了代码不知道我犯了什么错误
-
尝试在 for 循环之外声明 b。甚至可以使用 i 作为序列号。
-
@Smile 是的,我尝试在外部声明仍然相同..我已附加输出的 SS。
-
我删除了 pdfbox 标签,因为这与 pdfbox 无关。也许可以装箱,但据我所知,这通常是关于 java 的。
标签: java