如何在 Apache POI XLS 中直接存储数据?
我使用 Apache POI HSSF API for Java 生成一个很长的报告作为 XLS 文件。问题是日期非常大,并且在调用 wb.write(out); 之前我的内存就失败了。所以我想知道是否有某种方法可以直接或定期存储XLS报告的信息。
I use Apache POI HSSF API for Java to generate a long long report as XLS file. The problems is date is really large and my memory fails before calling wb.write(out);
. So I wonder if there is some way directly or periodically to store the information for the XLS report.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用最新版本的 POI 3.8 beta 并查看 SXSSF 模型,我知道他们正在尝试帮助从 xlsx 读入时的内存使用,但我不确定它如何与写出一起工作。 可能值得一看。
除此之外,我认为你唯一的选择是使用 -Xmx 增加 JVM 的堆空间。
我希望这有帮助!
You could try using the latest version of POI 3.8 beta and look into the SXSSF model, I'm know they are trying to help memory usage when reading in from an xlsx, but I'm not sure how it would work with writing out. Might be worth a look though.
Other than that I think you're only option is to up the heap space for your JVM by using -Xmx.
I hope this helps!
您需要关闭工作簿对象..确保其超出范围&再次重新打开文档。关闭文档后调用 System.gc() 可能会有所帮助。
最好增加
you need to close the workbook object.. ensure that its out of scope & reopen the document again.. it might help to call
System.gc()
after closing the document.its best to increase the max memory (heap space) allocated to java for better results.