简体   繁体   中英

Read the 100Mb xlsx file parse it in java and store it into mongodb? Fast

我想读取xlsx文件并存储到mongodb.file中大小最小为100mb。我想读取xlsx文件并将其解析为json并将其存储到mongodb中。

You can read XLSX files using Apache POI (like described here http://java67.blogspot.com/2014/09/how-to-read-write-xlsx-file-in-java-apache-poi-example.html ).

Since there is a limitation in 16 mb per document in mongodb ( http://docs.mongodb.org/master/reference/limits/ ) you might want to use GridFS to write raw data. Here is an example how to do it:

https://blog.codecentric.de/en/2012/11/mongodb-supplemental-gridfs-example-in-java/

[UPDATE] If you have actually many small documents in XLSX file (like document per row) then you can use batch-like way inserting documents by blocks (see How to insert multiple documents at once in MongoDB through Java as an example).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM