7
问题:
参考官方文档,实现复杂表头下载,相同的表头没有自动合并。
public void complexHeadWrite(HttpServletResponse response) {
String fileName = TestFileUtil.getPath() + "complexHeadWrite" + System.currentTimeMillis() + ".xlsx";
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,名字为模板 然后文件流会自动关闭
File file = new File("C:\\Users\\**1\\Desktop\\多sheet导出测试.xlsx");
EasyExcel.write(file, ComplexHeadData.class).sheet("模板").doWrite(data1());
}
@Getter
@Setter
@EqualsAndHashCode
public class ComplexHeadData {
@ExcelProperty({"主标题", "字符串标题"})
private String string;
@ExcelProperty({"主标题", "日期标题"})
private Date date;
@ExcelProperty({"主标题", "数字标题"})
private Double doubleData;
}
private List<DownloadData> data1() {
List<DownloadData> list = ListUtils.newArrayList();
for (int i = 0; i < 10; i++) {
DownloadData data = new DownloadData();
data.setString("字符串" + i);
data.setDate(new Date());
data.setDoubleData(0.56);
list.add(data);
}
return list;
}
异常现象