Browse Source

修复多个`sheet`不按照顺序写入 会乱序的bug #1332

developing
Jiaju Zhuang 5 years ago
parent
commit
39ed3a6738
  1. 6
      src/main/java/com/alibaba/excel/context/WriteContextImpl.java

6
src/main/java/com/alibaba/excel/context/WriteContextImpl.java

@ -163,14 +163,14 @@ public class WriteContextImpl implements WriteContext {
Sheet currentSheet; Sheet currentSheet;
try { try {
if (writeSheetHolder.getSheetNo() != null) { if (writeSheetHolder.getSheetNo() != null) {
int realSheetNo = writeSheetHolder.getSheetNo();
// When the add default sort order of appearance // When the add default sort order of appearance
if (WriteTypeEnum.ADD.equals(writeType)) { if (WriteTypeEnum.ADD.equals(writeType)) {
currentSheet = createSheet(); currentSheet = createSheet();
} else { } else {
currentSheet = writeWorkbookHolder.getWorkbook().getSheetAt(realSheetNo); currentSheet = writeWorkbookHolder.getWorkbook().getSheetAt(writeSheetHolder.getSheetNo());
writeSheetHolder writeSheetHolder
.setCachedSheet(writeWorkbookHolder.getCachedWorkbook().getSheetAt(realSheetNo)); .setCachedSheet(
writeWorkbookHolder.getCachedWorkbook().getSheetAt(writeSheetHolder.getSheetNo()));
} }
} else { } else {
// sheet name must not null // sheet name must not null

Loading…
Cancel
Save