();
+ map.put("date", "2019年10月9日13:28:28");
+ map.put("total", 1000);
+ excelWriter.fill(map, writeSheet);
+ excelWriter.finish();
+ }
+
+ /**
+ * 数据量大的复杂填充
+ *
+ * 这里的解决方案是 确保模板list为最后一行,然后再拼接table.还有03版没救,只能刚正面加内存。
+ *
+ * @since 2.1.1
+ */
+ @Test
+ public void complexFillWithTable() {
+ // 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"\{","\}"代替
+ // {} 代表普通变量 {.} 代表是list的变量
+ // 这里模板 删除了list以后的数据,也就是统计的这一行
+ String templateFileName = "D:\\test\\complex.xlsx";
+
+ String fileName = TestFileUtil.getPath() + "complexFillWithTable" + System.currentTimeMillis() + ".xlsx";
+ ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileName).build();
+ WriteSheet writeSheet = EasyExcel.writerSheet().build();
+ // 直接写入数据
+ excelWriter.fill(data(), writeSheet);
+ excelWriter.fill(data(), writeSheet);
+
+ // 写入list之前的数据
+ Map map = new HashMap();
+ map.put("date", "2019年10月9日13:28:28");
+ excelWriter.fill(map, writeSheet);
+
+ // list 后面还有个统计 想办法手动写入
+ // 这里偷懒直接用list 也可以用对象
+ List> totalListList = new ArrayList>();
+ List totalList = new ArrayList();
+ totalListList.add(totalList);
+ totalList.add(null);
+ totalList.add(null);
+ totalList.add(null);
+ // 第四列
+ totalList.add("统计:1000");
+ // 这里是write 别和fill 搞错了
+ excelWriter.write(totalListList, writeSheet);
+ excelWriter.finish();
+ // 总体上写法比较复杂 但是也没有想到好的版本 异步的去写入excel 不支持行的删除和移动,也不支持备注这种的写入,所以也排除了可以
+ // 新建一个 然后一点点复制过来的方案,最后导致list需要新增行的时候,后面的列的数据没法后移,后续会继续想想解决方案
+ }
+
+ private List data() {
+ List list = new ArrayList();
+ for (int i = 0; i < 10; i++) {
+ FillData fillData = new FillData();
+ list.add(fillData);
+ fillData.setName("张三");
+ fillData.setNumber(5.2);
+ }
+ return list;
+ }
+}
diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiTest.java
index 367ee583..f7778338 100644
--- a/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiTest.java
+++ b/src/test/java/com/alibaba/easyexcel/test/temp/poi/PoiTest.java
@@ -79,11 +79,11 @@ public class PoiTest {
@Test
public void lastRowNum255() throws IOException, InvalidFormatException {
- String file = TestFileUtil.getPath() + "fill" + File.separator + "complex.xlsx";
+ String file = "D:\\test\\complex.xlsx";
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new File(file));
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(xssfWorkbook);
Sheet xssfSheet = xssfWorkbook.getSheetAt(0);
- xssfSheet.shiftRows(2, 4, 10);
+ xssfSheet.shiftRows(1, 4, 10, true, true);
FileOutputStream fileout = new FileOutputStream("d://test/r2" + System.currentTimeMillis() + ".xlsx");
sxssfWorkbook.write(fileout);
diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/read/HDListener.java b/src/test/java/com/alibaba/easyexcel/test/temp/read/HDListener.java
index 196b2da9..e52dc51a 100644
--- a/src/test/java/com/alibaba/easyexcel/test/temp/read/HDListener.java
+++ b/src/test/java/com/alibaba/easyexcel/test/temp/read/HDListener.java
@@ -25,6 +25,7 @@ public class HDListener extends AnalysisEventListener {
@Override
public void invokeHeadMap(Map headMap, AnalysisContext context) {
LOGGER.info("HEAD:{}", JSON.toJSONString(headMap));
+ LOGGER.info("total:{}", context.readSheetHolder().getTotal());
}
diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadData.java b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadData.java
index 38ee661f..538e2663 100644
--- a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadData.java
+++ b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadData.java
@@ -3,6 +3,7 @@ package com.alibaba.easyexcel.test.temp.read;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
+import lombok.experimental.Accessors;
/**
* 临时测试
@@ -10,6 +11,7 @@ import lombok.Data;
* @author Jiaju Zhuang
**/
@Data
+@Accessors(chain = true)
public class HeadReadData {
@ExcelProperty("头1")
private String h1;
diff --git a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java
index f356524a..5127f72f 100644
--- a/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java
+++ b/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java
@@ -2,6 +2,7 @@ package com.alibaba.easyexcel.test.temp.read;
import java.io.File;
+import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -13,13 +14,15 @@ import com.alibaba.excel.EasyExcel;
*
* @author Jiaju Zhuang
**/
+@Ignore
public class HeadReadTest {
private static final Logger LOGGER = LoggerFactory.getLogger(HeadReadTest.class);
@Test
public void test() throws Exception {
- File file = new File("D:\\test\\headt1.xlsx");
- EasyExcel.read(file, HeadReadData.class, new HDListener()).sheet().doRead();
+ File file = new File("D:\\test\\headt1.xls");
+ EasyExcel.read(file, HeadReadData.class, new HDListener()).sheet(0).doRead();
+
}
}
diff --git a/update.md b/update.md
index 4055d43d..9bd246e5 100644
--- a/update.md
+++ b/update.md
@@ -7,6 +7,11 @@
* 加入多次关闭判断,防止多次关闭异常
* 加入根据模板自动识别导出的excel类型
* 修改默认失败后,不再往文件流写入数据。通过参数`writeExcelOnException` 参数设置异常了也要写入前面的数据。
+* 循环合并策略支持一次性合并多列
+* `ExcelDataConvertException`返回新增具体报错的数据
+* 加入解析class缓存
+* 修复填充的时候行高不复制的Bug [Issue #780](https://github.com/alibaba/easyexcel/issues/780)
+* 修复03版无法获取大概总行数的bug
# 2.1.0-beta4
* 修改最长匹配策略会空指针的bug [Issue #747](https://github.com/alibaba/easyexcel/issues/747)