help wanted
Description
建议先去看文档
异常代码
private Flux<DataBuffer> getData( ) {
return Flux.create(sink -> {
ClassPathResource classPathResource = new ClassPathResource(
"template.xlsx");
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
InputStream inputStream = classPathResource .getInputStream();
ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(inputStream).build(); ) {
WriteSheet writeSheet = EasyExcel.writerSheet().build();
while (dataList.isNotEmpty()) {
excelWriter.fill(dataList, writeSheet);
sink.next(convertOutputStreamToDataBuffer(outputStream));
outputStream.reset();
dataList=getList();
}
excelWriter.finish();
sink.complete();
} catch (Exception e) {
log.error("发送分片数据异常:{}", e);
sink.error(e);
}
});
}
异常提示
无异常但是使用webflux 返回文件无数据
问题描述
以上代码运行时无法按照所想的结果分批次返回fill的文件块,断点上看似乎是因为excelWriter.finish()时outputStream中才有数据? 假如数据集比较大 需要采用分次fill的形式 我需要在每次fill之后获取有数据的outputStream 应该怎么做?