mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
ae16121e46
commit
a1b56d03c6
@ -376,7 +376,7 @@ public class ExcelWriteTest {
|
|||||||
|
|
||||||
List<Map<Object, Object>> rows = CollUtil.newArrayList(row1, row2);
|
List<Map<Object, Object>> rows = CollUtil.newArrayList(row1, row2);
|
||||||
// 通过工具类创建writer
|
// 通过工具类创建writer
|
||||||
String file = "f:/test/test_alias.xls";
|
String file = "d:/test/test_alias.xls";
|
||||||
ExcelWriter writer = ExcelUtil.getWriter(file, "test1");
|
ExcelWriter writer = ExcelUtil.getWriter(file, "test1");
|
||||||
// writer.setOnlyAlias(true);
|
// writer.setOnlyAlias(true);
|
||||||
// 自定义标题
|
// 自定义标题
|
||||||
@ -388,6 +388,40 @@ public class ExcelWriteTest {
|
|||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void writeMapOnlyAliasTest3() {
|
||||||
|
Map<Object, Object> row1 = new LinkedHashMap<>();
|
||||||
|
row1.put("name", "张三");
|
||||||
|
row1.put("age", 22);
|
||||||
|
row1.put("isPass", true);
|
||||||
|
row1.put("score", 66.30);
|
||||||
|
row1.put("examDate", DateUtil.date());
|
||||||
|
|
||||||
|
Map<Object, Object> row2 = new LinkedHashMap<>();
|
||||||
|
row2.put("name", "李四");
|
||||||
|
// row2.put("age", 233);
|
||||||
|
row2.put("isPass", false);
|
||||||
|
row2.put("score", 32.30);
|
||||||
|
row2.put("examDate", DateUtil.date());
|
||||||
|
|
||||||
|
List<Map<Object, Object>> rows = CollUtil.newArrayList(row1, row2);
|
||||||
|
// 通过工具类创建writer
|
||||||
|
String file = "d:/test/test_alias.xls";
|
||||||
|
ExcelWriter writer = ExcelUtil.getWriter(file, "test1");
|
||||||
|
writer.setOnlyAlias(true);
|
||||||
|
|
||||||
|
// 自定义标题
|
||||||
|
writer.addHeaderAlias("name", "姓名");
|
||||||
|
writer.addHeaderAlias("age", "年龄");
|
||||||
|
writer.addHeaderAlias("examDate", "考试时间");
|
||||||
|
|
||||||
|
// 一次性写出内容,使用默认样式
|
||||||
|
writer.write(rows, true);
|
||||||
|
// 关闭writer,释放内存
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
@Ignore
|
||||||
public void writeBeanTest() {
|
public void writeBeanTest() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user