最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to edit large Excel file with Apache POI? - Stack Overflow

programmeradmin0浏览0评论

I'm working with Excel files that are 20MB+ and contain 100,000+ records. I tried increasing my heap size, but then ran into error "Could not reserve enough space for 2097152KB object heap". Max I can currently set it to is 1GB, but I'm still getting heap memory error.

My code already blows up when I try to read the excel file like this:

try (FileInputStream is = new FileInputStream(new File(excelFilePath));
     Workbook newWorkBook = new XSSFWorkbook(is)) {

The part where I'm initialising the workbook, it blows up with the error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

So I need to edit the Excel files and add some values. How do I go about this and avoid this memory issue I'm dealing with? If I'm having this memory issue, I don't understand how I'm gonna be able to overwrite the file with the changes I've made.

发布评论

评论列表(0)

  1. 暂无评论