mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix poi bug
This commit is contained in:
parent
185764ec75
commit
7ead906910
@ -3,7 +3,7 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.7.2 (2021-06-17)
|
||||
# 5.7.2 (2021-06-18)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 增加UserPassAuthenticator
|
||||
@ -13,6 +13,7 @@
|
||||
### 🐞Bug修复
|
||||
* 【db 】 修复Oracle下别名错误造成的SQL语法啊错误(issue#I3VTQW@Gitee)
|
||||
* 【core 】 修复ConcurrencyTester重复使用时开始测试未清空之前任务的问题(issue#I3VSDO@Gitee)
|
||||
* 【poi 】 修复使用BigWriter写出,ExcelWriter修改单元格值失败的问题(issue#I3VSDO@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
<properties>
|
||||
<!-- versions -->
|
||||
<cglib.version>3.3.0</cglib.version>
|
||||
<spring.version>5.3.7</spring.version>
|
||||
<spring.version>5.3.8</spring.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -218,6 +218,14 @@ public class CellUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
// issue#1659@Github
|
||||
// 在使用BigWriter(SXSSF)模式写出数据时,单元格值为直接值,非引用值(is标签)
|
||||
// 而再使用ExcelWriter(XSSF)编辑时,会写出引用值,导致失效。
|
||||
// 此处做法是先清空单元格值,再写入
|
||||
if(CellType.BLANK != cell.getCellType()){
|
||||
cell.setBlank();
|
||||
}
|
||||
|
||||
if (null == value) {
|
||||
cell.setCellValue(StrUtil.EMPTY);
|
||||
} else if (value instanceof FormulaCellValue) {
|
||||
|
@ -21,7 +21,10 @@ import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
@ -570,4 +573,31 @@ public class ExcelWriteTest {
|
||||
// 关闭writer,释放内存
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* issue#1659@Github
|
||||
* 测试使用BigWriter写出,ExcelWriter修改失败
|
||||
*/
|
||||
@Test
|
||||
@Ignore
|
||||
public void editTest(){
|
||||
// 生成文件
|
||||
File file = new File("d:/test/100_.xlsx");
|
||||
FileUtil.del(file);
|
||||
|
||||
BigExcelWriter writer = ExcelUtil.getBigWriter(file);
|
||||
writer.disableDefaultStyle();
|
||||
List<List<String>> rows = Collections.singletonList(Arrays.asList("哈哈", "嘿嘿"));
|
||||
writer.write(rows);
|
||||
writer.close();
|
||||
|
||||
// 修改文件
|
||||
ExcelWriter writer2 = ExcelUtil.getWriter(file);
|
||||
writer2.disableDefaultStyle();
|
||||
writer2.writeCellValue(0, 0, "a");
|
||||
writer2.close();
|
||||
|
||||
final ExcelReader reader = ExcelUtil.getReader(file);
|
||||
Console.log(reader.read());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user