bengbengbalabalabeng commented on issue #794:
URL: https://github.com/apache/fesod/issues/794#issuecomment-3743883297
Based on my understanding, it should only be necessary to change the
`writeSheetHolder` in the `if` condition to `currentWriteHolder`, while keeping
the rest of the logic unchanged.
After changed demo:
<details>
<summary>View full code</summary>
```java
ExcelWriterBuilder write = FastExcelFactory.write(OUTPUT);
ExcelWriterSheetBuilder sheetBuilder = write.sheet(0, "测试");
WriteSheet sheet = sheetBuilder.build();
WriteSheet collect = sheetBuilder
.relativeHeadRowIndex(1)
.head(ExcelModel.class)
.build();
WriteTable tableA = sheetBuilder.table(0)
.relativeHeadRowIndex(3)
.head(TableA.class)
.build();
WriteTable tableB = sheetBuilder.table(1)
.relativeHeadRowIndex(6)
.head(TableB.class)
.build();
try (ExcelWriter writer = write.build()) {
for (int i = 1; i <= 1; i++) {
List<ExcelModel> dataList = new ArrayList<>();
for (int j = 0; j < 10; j++) {
ExcelModel result = new ExcelModel();
result.setSchool("湘北高中");
result.setClazz("一班");
result.setNo("00" + j);
dataList.add(result);
}
writer.write(dataList, collect);
}
for (int i = 1; i <= 1; i++) {
List<TableA> dataList = new ArrayList<>();
for (int j = 0; j < 10; j++) {
TableA result = new TableA();
result.setName("张三");
result.setAge(18);
result.setDate(new Date());
dataList.add(result);
}
writer.write(dataList, sheet, tableA);
}
for (int i = 1; i <= 1; i++) {
List<TableB> dataList = new ArrayList<>();
for (int j = 0; j < 10; j++) {
TableB result = new TableB();
result.setHeight(180);
result.setAddress("北京");
result.setPhone("12345678901");
dataList.add(result);
}
writer.write(dataList, sheet, tableB);
}
writer.finish();
}
```
</details>
Output:
<img width="238" height="660" alt="Image"
src="https://github.com/user-attachments/assets/600d92fd-fdf4-4864-bc27-abcab96cf518"
/>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]