easyexcel写入ByteArrayOutputStream
easyexcel
快速、简洁、解决大文件内存溢出的java处理Excel工具
项目地址:https://gitcode.com/gh_mirrors/ea/easyexcel
·
定义ExcelViewObject
public class ExcelViewObject {
@ColumnWidth(12)
@ExcelProperty(value = "首列")
private String type;
@ColumnWidth(12)
@ExcelProperty(value = "第二列")
private String name;
}
插入数据,输出到ByteArrayOutputStream;ByteArrayOutputStream作为常用的字节流,输出后可以作为接口数据来传送;
ByteArrayOutputStream out = new ByteArrayOutputStream();
List<ExcelViewObject> data = new ArrayList<>();
将要插入的数据遍历插入,如果不需转换直接addAll();
for (POObject item : list) {
ExcelViewObject excelViewObject = new ExcelViewObject();
BeanUtils.copyProperties(item, excelViewObject);
data.add(ExcelViewObject);
}
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
HorizontalCellStyleStrategy horizontalCellStyleStrategy =
new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
EasyExcel.write(out, ExcelViewObject.class)
.registerWriteHandler(horizontalCellStyleStrategy).sheet().doWrite(data);
快速、简洁、解决大文件内存溢出的java处理Excel工具
最近提交(Master分支:3 个月前 )
c42183df
Bugfix 1 年前
efa7dff6 * 重新加回 `commons-io`
1 年前
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)