Large Excel File - Upload and Import - Java

巧了我就是萌 提交于 2019-12-12 02:25:16

问题


all

I want to upload and import a large excel files having more than one million records in to my Java program.

I can easily import small files using Apache POI in to my system , but when i starts with large files application throws and out of memory error,

i searched google and found many threads on so , i tried everything but could not get around of this.

can anybody give me solution for my particular problem, import time is not an issue for me, right now also i can bear with performance issue as well,

just want to import this data in to my existing system without oem error.

I have very good configuration on my system and java has enough memory to use so hardware is not an issue.

Thanks


回答1:


You'll want to stream the data so that you don't need to store all the records in memory at once. POI does support streaming (see XSSF and SAX event API). As you read the data, ship it off to wherever you need to (database or wherever, you did not specify) -- with the streaming API you should not read all the data into memory before processing it.

You could also export the data to a CSV file, and then use a regular FileInputStream to read the file and process each record as it is read.



来源:https://stackoverflow.com/questions/21360220/large-excel-file-upload-and-import-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!