This commit is contained in:
Looly 2019-10-11 17:25:07 +08:00
parent 781b8efb72
commit c16edabb7d
4 changed files with 44 additions and 6 deletions

View File

@ -22,11 +22,5 @@
<artifactId>hutool-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -367,6 +367,34 @@ public class ExcelWriteTest {
writer.close();
}
@Test
@Ignore
public void writeBeanTest2() {
OrderExcel order1 = new OrderExcel();
order1.setId("1");
order1.setNum("123");
order1.setBody("body1");
OrderExcel order2 = new OrderExcel();
order1.setId("2");
order1.setNum("456");
order1.setBody("body2");
List<OrderExcel> rows = CollUtil.newArrayList(order1, order2);
// 通过工具类创建writer
String file = "f:/test/writeBeanTest2.xlsx";
FileUtil.del(file);
ExcelWriter writer = ExcelUtil.getWriter(file);
// 自定义标题
writer.addHeaderAlias("id", "编号");
writer.addHeaderAlias("num", "序号");
writer.addHeaderAlias("body", "内容");
// 一次性写出内容使用默认样式
writer.write(rows, true);
// 关闭writer释放内存
writer.close();
}
@Test
@Ignore
public void writeCellValueTest() {

View File

@ -0,0 +1,10 @@
package cn.hutool.poi.excel.test;
import lombok.Data;
@Data
public class OrderExcel {
private String id;
private String num;
private String body;
}

View File

@ -53,6 +53,12 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<issueManagement>