From a7db3cf041b0824ddffcb48cbd5c7ad922ab459c Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Wed, 22 Apr 2020 20:38:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E7=B1=BB=E7=9A=84=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=8C=89=E7=85=A7ExcelProperty=E7=9A=84?= =?UTF-8?q?=E5=B1=9E=E6=80=A7index=E9=A1=BA=E5=BA=8F=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=86=99=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E9=94=99=E4=B9=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../easyexcel/test/temp/simple/Wirte.java | 2 +- .../easyexcel/test/temp/simple/WriteData.java | 3 +++ .../test/temp/simple/WriteHandler.java | 21 +++++++++++++++++++ update.md | 5 +++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteHandler.java diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/simple/Wirte.java b/src/test/java/com/alibaba/easyexcel/test/temp/simple/Wirte.java index 6157181..d2367ba 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/simple/Wirte.java +++ b/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 diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteData.java b/src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteData.java index b8ff14d..b9de59b 100644 --- a/src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteData.java +++ b/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; } diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteHandler.java b/src/test/java/com/alibaba/easyexcel/test/temp/simple/WriteHandler.java new file mode 100644 index 0000000..1420b2b --- /dev/null +++ b/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"); + } +} diff --git a/update.md b/update.md index 409fc6e..a4b9a75 100644 --- a/update.md +++ b/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