且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

POI读取现有Excel和大型数据编辑

更新时间:2023-08-24 21:32:10

有是一个银弹简单的答案可使用几个选项,但没有。遗憾的是,Excel文件格式确实需要的内存公平位的工作。

There are a few options available, but none that are a "silver bullet" simple answer. Unfortunately, the Excel file formats do require a fair bit of memory to work with.


  1. 增加提供给Java的堆大小,因此它可以同时容纳更多的内存

  2. 购买一些更多的内存,为您的服务器,然后增加堆的大小。内存为pretty便宜这些天,它并不需要一个体面的程序员非常多小时工资标准支付费用

  3. 使用不同的文件格式 - CSV例如是内存占用
  4. 非常轻巧
  5. 使用href=\"http://poi.apache.org/s$p$padsheet/how-to.html#low_level_api\" rel=\"nofollow\">低水平SAX API 以阅读 SXSSF 写它同样没有太多缓冲。需要相当多的自定义编码的,虽然,因为你更多的工作比只使用HSSF / XSSF

  6. /参与赞助的内存改进到Apache POI的贡献。 POI是开源的,免费的,并且完全由志愿者维护,因此如果事情对你很重要,你是经常***关闭帮助!

  1. Increase the heap size given to Java, so it can hold more in memory at a time
  2. Buy some more memory for your server, then increase the heap size. Memory is pretty cheap these days, and it doesn't take very many hours wage of a decent programmer to cover the cost
  3. Use a different file format - CSV for example is very lightweight on the memory footprint
  4. Use the low level SAX API to read in the .xlsx file, then use SXSSF to write it out again without much buffering. Needs quite a lot of custom coding though, much more work for you than just using HSSF/XSSF
  5. Contribute / sponsor the contribution of memory improvements to Apache POI. POI is open source, freely available, and maintained entirely by volunteers, so if something matters to you you're often best off helping!