admin 管理员组

文章数量: 1086019

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.

本文标签: javaHow to edit large Excel file with Apache POIStack Overflow