[英]Java - read, process, write with large excel
I have a large spread sheet. 我的床单很大。 It has 10 sheets, each with 1m rows.
它有10张纸,每张纸有1m行。 With Java, I need to run an algorithm for each row, return a value for each row and insert back into the excel file.
使用Java,我需要为每一行运行一个算法,为每一行返回一个值,然后再插入到excel文件中。
My idea was to load the file into ram, do calculations for each row, store the result in a list, and insert back to excel in order, but I didn't anticipate the issues dealing with the data size. 我的想法是将文件加载到ram中,对每一行进行计算,将结果存储在列表中,然后按顺序插入到excel中,但是我没有想到处理数据大小的问题。
I tried XSSF, and it wasn't able to load such a large file. 我尝试了XSSF,但它无法加载这么大的文件。 After waiting for a few hours it gave me the OOM error.
等待了几个小时后,它给了我OOM错误。
I tried increasing heap in run->run configurations->arguments, and in control panel->java. 我尝试在运行->运行配置->参数以及控制面板-> Java中增加堆。 It didn't work.
没用
I tried using the following StreamingReader and it didn't work. 我尝试使用以下StreamingReader,但无法正常工作。
FileInputStream in = new FileInputStream("D:\\work\\calculatepi\\sampleresult.xlsx");
Workbook workbook = StreamingReader.builder()
.rowCacheSize(100)
.bufferSize(4096)
.open(in);
I'm really out of clue and not sure what to do. 我真的不知道该怎么办。 Is there no easy way to do this?
有没有简单的方法可以做到这一点?
It is not only about the configuration of that library. 它不仅与该库的配置有关。 It is also about the memory that you give to you JVM!
这也与您为JVM提供的内存有关! Try increasing the heap space of the JVM, see here for example.
尝试增加JVM的堆空间,例如,请参见此处 。
Beyond that: I think you should do two things: 除此之外:我认为您应该做两件事:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.