Comments (5)
目前支持的是在文件未关闭的情况下是可以持续读写,不用担心内存溢出问题,因为默认5000条数据是会flush到磁盘的。你所说的保存后再读写以前我没遇到过这种场景,确实没这么写过。
from easyexcel.
能够把你的场景,我看下合理性是否一定需要文件写已经关闭了再写呢?
from easyexcel.
public class LocalTest {
public static void main(String[] args) {
String exportFilePath = "E:\\LocalTest.xlsx";
Integer baseIndex = 0;
for (int index = 0; index < 3; index++) {
doExport(exportFilePath, baseIndex);
baseIndex = baseIndex + 10000;
}
}
private static void doExport(String exportFilePath, Integer baseIndex) {
List<Order> orderList = new ArrayList<>();
for (int index = 0; index < 10000; index++) {
Order order = new Order();
order.setFOrderId("FOrderId" + index + baseIndex);
order.setFMerchantId("FMerchantId" + index + baseIndex);
order.setFUserName("FUserName" + index + baseIndex);
order.setFState(new Random().nextInt(3));
order.setFAmount(new Random().nextInt(1000000));
order.setFRefundAmount(new Random().nextInt(1000000));
order.setFGoodsType("FGoodsType" + index + baseIndex);
order.setFGoodsName("FGoodsName" + index + baseIndex);
order.setFGoodsDetail("FGoodsDetail" + index + baseIndex);
order.setFTime(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
orderList.add(order);
}
EasyExcelUtil.export(exportFilePath, orderList, Order.class, ExcelTypeEnum.XLSX);
}
}
public class EasyExcelUtil {
public static <T extends BaseMeta> void export(String exportFilePath, List<T> metaList, Class clazz, ExcelTypeEnum excelTypeEnum) {
try {
OutputStream outputStream = new FileOutputStream(exportFilePath);
ExcelWriter excelWriter = new ExcelWriter(outputStream, excelTypeEnum);
Sheet sheet1 = new Sheet(1, 0, clazz);
excelWriter.write(metaList, sheet1);
excelWriter.finish();
} catch (FileNotFoundException exception) {
System.out.println("EasyExcelUtil.export(), FileNotFoundException: " + exception);
}
}
}
以上是我的代码,一个简单的测试DEMO,请看下。
from easyexcel.
OK,和我理解的是一样的,暂时不要在Excel没有写完的时候就去调finish().一个Excel写完再Finish()。内存问题不用担心。不过使用者确实可能会像你这样使用。后续版本优化这个问题
from easyexcel.
重新读取文件续写这个功能有加上吗?
from easyexcel.
Related Issues (20)
- 无法正确拿到表头字体样式 HOT 1
- 生成的excel自定义格式@NumberFormat(value = "0!.0,")将数字转成万为单位保留一位小数在wps中正常展示,office格式错误 HOT 4
- 使用SheetWriteHandler写入csv文件时空指针异常 HOT 1
- 请问现在是否支持一对多的导出模式了呢 HOT 1
- 总行数获取与实际不符合 HOT 3
- CellStyle设置主动换行后,变成表头样式,单元格不生效
- 读取合并的表头问题 HOT 1
- 4.0.0版本依赖commons-io版本过低导致异常 HOT 4
- 设置字体为微软雅黑,导致和动态合并单元格冲突 HOT 1
- 自定义行高 无法进入重写方法
- 使用FillConfig.builder().forceNewRow(true)函数之后,他会将我需要的固定行还是给覆盖掉,大佬有解决方法不
- 不创建对象时,Converter中的ExcelContentProperty.getField为null
- 导出文件慢 HOT 1
- 如何支持内容单元格背景色交替显示 HOT 1
- 图片byte[]类型导出 与自定义的hanlder重复 也无法关闭
- 使用cglib生成类的话无法使用graalvm打包成native镜像,希望可以加一个ModelBuildEventListener选项换一种方式转换实体类 HOT 1
- 自定义handler影响doWrite
- Excel单元格宽度固定,单元格内容非常多导致一个单元格显示不下所有内容,现有方法可以让单元格内容完全显示吗?多谢! HOT 5
- 版本3.1.1,EasyExcel导出支持千分位 HOT 5
- 最新版本4.0.1 单元格最大字符数是多少 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyexcel.