Reading a range of excel sheet data using POI

2019-07-19 16:30发布

问题:

I am doing some POC on reading data within a range from an excel file to an array in Java in singleshot.

I have to read an excel file using POI in Java where the no: of rows will be near to 1,00,000 and the no: of columns will be near to 240. Most of the examples which I got from internet tells about using rowIterator and cellIterator for getting this job done. But since the rowcount and columncount is huge, iterating through each cell and adding data to an array is not a feasible solution.

Is there any method in POI API which will fetch a range of cells in one shot and transfer it to an array in java?

I am still going through the POI API, but was not successful in finding a solution till now. If someone knows about such a method, can you illustrate it with a small working example?

回答1:

CellWalk might help. see http://poi.apache.org/apidocs/org/apache/poi/ss/util/cellwalk/CellWalk.html

You can find a sample use here: http://svn.apache.org/repos/asf/poi/trunk/src/testcases/org/apache/poi/ss/util/cellwalk/TestCellWalk.java