81,092
社区成员
发帖
与我相关
我的任务
分享
for (int i = 0; i < list.size(); i++) { // 循环章
Outline entity = list.get(i);
List<Outline> child=entity.getChild();
ws.mergeCells(0, count, 0, child.size()+count-1);// 合并章的单元格
for(int j = 0; j < child.size(); j++){// 循环节
Outline entity1 = child.get(j);
List<CourseContent> content=entity1.getContent();
ws.mergeCells(1, num, 1, content.size()+num-1);// 合并节的单元格
for(int k = 0; k < content.size(); k++){// 循环单元
CourseContent entity2 = content.get(k);
ws.addCell(new Label(1, num + k, "" + entity1.getTitle(),cellFontFormat));// 节 的内容
ws.addCell(new Label(2, k + 1, "" + entity2.getTitle(),cellFontFormat));// 单元内容
}
ws.addCell(new Label(0, count + j, "" + entity.getTitle(),cellFontFormat));
num+=content.size(
把你想要获取对象的变量定义写在最外面。
代码好像不全吧。。 在最外层for循环之前声明个List<你要的对象> list 最里头循环 把对象add到这个list里 是要这样的效果吗