mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
解决冲突
This commit is contained in:
@@ -16,7 +16,12 @@ import org.apache.poi.ss.usermodel.IndexedColors;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 写出Excel单元测试
|
||||
@@ -218,17 +223,24 @@ public class BigExcelWriteTest {
|
||||
@Ignore
|
||||
public void issue1210() {
|
||||
// 通过工具类创建writer
|
||||
String path = "e:/issue1210.xlsx";
|
||||
String path = "d:/test/issue1210.xlsx";
|
||||
FileUtil.del(path);
|
||||
BigExcelWriter writer = ExcelUtil.getBigWriter(path);
|
||||
writer.addHeaderAlias("id", "SN");
|
||||
writer.addHeaderAlias("userName", "User Name");
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
list.add(new HashMap<String, Object>() {{
|
||||
list.add(new HashMap<String, Object>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
put("id", 1);
|
||||
put("userName", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
}});
|
||||
list.add(new HashMap<String, Object>() {{
|
||||
|
||||
list.add(new HashMap<String, Object>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
{
|
||||
put("id", 2);
|
||||
put("userName", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
|
||||
}});
|
||||
|
@@ -3,6 +3,7 @@ package cn.hutool.poi.excel.test;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import lombok.Data;
|
||||
@@ -186,6 +187,7 @@ public class ExcelReadTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void readCellsTest() {
|
||||
final ExcelReader reader = ExcelUtil.getReader("merge_test.xlsx");
|
||||
reader.read((cell, value)-> Console.log("{}, {} {}", cell.getRowIndex(), cell.getColumnIndex(), value));
|
||||
@@ -201,4 +203,20 @@ public class ExcelReadTest {
|
||||
Console.log(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullValueEditTest(){
|
||||
final ExcelReader reader = ExcelUtil.getReader("null_cell_test.xlsx");
|
||||
reader.setCellEditor((cell, value)-> ObjectUtil.defaultIfNull(value, "#"));
|
||||
final List<List<Object>> read = reader.read();
|
||||
|
||||
// 对于任意一个单元格有值的情况下,之前的单元格值按照null处理
|
||||
Assert.assertEquals(1, read.get(1).size());
|
||||
Assert.assertEquals(2, read.get(2).size());
|
||||
Assert.assertEquals(3, read.get(3).size());
|
||||
|
||||
Assert.assertEquals("#", read.get(2).get(0));
|
||||
Assert.assertEquals("#", read.get(3).get(0));
|
||||
Assert.assertEquals("#", read.get(3).get(1));
|
||||
}
|
||||
}
|
||||
|
BIN
hutool-poi/src/test/resources/null_cell_test.xlsx
Normal file
BIN
hutool-poi/src/test/resources/null_cell_test.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user