Browse Source

当类的属性没有按照ExcelProperty的属性index顺序排序的时候,写数据出现错乱

developing
Jiaju Zhuang 5 years ago
parent
commit
a7db3cf041
  1. 2
      src/test/java/com/alibaba/easyexcel/test/temp/simple/Wirte.java
  2. 3
      src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteData.java
  3. 21
      src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteHandler.java
  4. 5
      update.md

2
src/test/java/com/alibaba/easyexcel/test/temp/simple/Wirte.java

@ -53,7 +53,7 @@ public class Wirte {
String fileName = TestFileUtil.getPath() + "t22" + System.currentTimeMillis() + ".xlsx";
// 这里 需要指定写用哪个class去读,然后写到第一个sheet,名字为模板 然后文件流会自动关闭
// 如果这里想使用03 则 传入excelType参数即可
EasyExcel.write(fileName, WriteData.class).sheet("模板").doWrite(data1());
EasyExcel.write(fileName, WriteData.class).sheet("模板").registerWriteHandler(new WriteHandler()).doWrite(data1());
}
@Test

3
src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteData.java

@ -1,5 +1,7 @@
package com.alibaba.easyexcel.test.temp.simple;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import lombok.Data;
/**
@ -9,5 +11,6 @@ import lombok.Data;
**/
@Data
public class WriteData {
@ContentStyle(locked = true)
private float f;
}

21
src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteHandler.java

@ -0,0 +1,21 @@
package com.alibaba.easyexcel.test.temp.simple;
import com.alibaba.excel.write.handler.AbstractSheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import lombok.extern.slf4j.Slf4j;
/**
* @author Jiaju Zhuang
*/
@Slf4j
public class WriteHandler extends AbstractSheetWriteHandler {
@Override
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder,
WriteSheetHolder writeSheetHolder) {
log.info("锁住");
writeSheetHolder.getSheet().protectSheet("edit");
}
}

5
update.md

@ -1,3 +1,8 @@
# 2.2.1
* 发布正式版
* 修复第一行为空不会调用`invokeHeadMap`的bug [Issue #993](https://github.com/alibaba/easyexcel/issues/993)
* 当类的属性没有按照ExcelProperty的属性index顺序排序的时候,写数据出现错乱 [Issue #1046](https://github.com/alibaba/easyexcel/issues/1046)
# 2.2.0-beta2
* 修复最长匹配策略不同表格会有影响的bug [Issue #1010](https://github.com/alibaba/easyexcel/issues/1010)
* `LinkedList`写入的性能问题 #1121

Loading…
Cancel
Save