[alibaba/easyexcel]导出数据设置head,会出现多行head

2023-12-10 479 views
6
异常代码
WriteSheet writeSheet = EasyExcelFactory.writerSheet().build();
// writeSheet.setHead(head);
WriteWorkBook writeWorkBook = new WriteWorkBook();
writeWorkBook.setExcelType(ExcelTypeEnum.CSV);
writeWorkBook.setOutputStream(httpServletResponse.getOutputStream());
writeWorkBook.setNeedHead(true);
writeWorkBook.setHead(head);
writeWorkBook.setAutoCloseStream(false);
ExcelWriter excelWriter = new ExcelWriter(writeWorkBook);
ExcelWriterTableBuilder excelWriterTableBuilder = new ExcelWriterTableBuilder(excelWriter,writeSheet);
excelWriterTableBuilder.doWrite(data); 
问题描述

writeSheet或者writeWorkBook设置 head,都会导致导出的数据出现两行head

回答

6

参考文档api来设置头吧

5

导出csv文件,还有其他方式吗,这个方式我看设置head只有在这两个位置设置

4

参考com.alibaba.easyexcel.test.demo.web.WebTest, 导出文件名后缀改成csv