Browse Source

修改模板通过流创建报错的bug

developing
Jiaju Zhuang 5 years ago
parent
commit
01d54cedc3
  1. 2
      src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java
  2. 16
      src/test/java/com/alibaba/easyexcel/test/temp/simple/Wirte.java
  3. 4
      update.md

2
src/main/java/com/alibaba/excel/write/metadata/holder/WriteWorkbookHolder.java

@ -146,7 +146,7 @@ public class WriteWorkbookHolder extends AbstractWriteHolder {
byte[] templateFileByte = null;
if (writeWorkbook.getTemplateFile() != null) {
templateFileByte = FileUtils.readFileToByteArray(writeWorkbook.getTemplateFile());
} else if (writeWorkbook.getTemplateInputStream() == null) {
} else if (writeWorkbook.getTemplateInputStream() != null) {
try {
templateFileByte = IoUtils.toByteArray(writeWorkbook.getTemplateInputStream());
} finally {

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

@ -5,12 +5,15 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.easyexcel.test.core.large.LargeData;
import com.alibaba.easyexcel.test.core.simple.SimpleData;
import com.alibaba.easyexcel.test.demo.write.DemoData;
import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel;
@ -18,6 +21,8 @@ import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON;
import net.sf.cglib.beans.BeanMap;
/**
* 测试poi
*
@ -27,6 +32,17 @@ import com.alibaba.fastjson.JSON;
public class Wirte {
private static final Logger LOGGER = LoggerFactory.getLogger(Wirte.class);
@Test
public void simpleWrite1() {
LargeData ss = new LargeData();
ss.setStr23("ttt");
Map map = BeanMap.create(ss);
System.out.println(map.containsKey("str23"));
System.out.println(map.containsKey("str22"));
System.out.println(map.get("str23"));
System.out.println(map.get("str22"));
}
@Test
public void simpleWrite() {
// 写法1

4
update.md

@ -1,3 +1,7 @@
# 2.1.0-beta2
* 修改模板通过流创建报错的bug
*
# 2.1.0-beta1
* 新增支持导入、导出支持公式
* 新增支持读取单元格类型、写入指定单元格类型

Loading…
Cancel
Save