I'm facing OutOfMemoryError when I try to read, format and write a line from a xlsx file with 23MB. I have a requirement to format only the header of the file.
I've tried with InputStream, File and OPCPackage:
1)
InputStream inp = new FileInputStream(path);
XSSFWorkbook wb = (XSSFWorkbook) WorkbookFactory.create(inp);
2)
InputStream inp = new FileInputStream(path);
File file = new File(path);
Files.copy(inp, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
XSSFWorkbook wb = (XSSFWorkbook) WorkbookFactory.create(file);
3)
OPCPackage pkg = OPCPackage.open(path);
XSSFWorkbook wb = (XSSFWorkbook) WorkbookFactory.create(pkg);
No success at all.
I have seen some examples using XSSFReader, SXSSFWorkbook, but it couldn't resolve my case because I need to overwrite the line, so I think I really need a Workbook.
Does anybody have implemented a read and write operation using Apache POI with a large xlsx file?
PS: In case the solution is to generate another file I need the format of the original file because the content is already formatted.