Search xlsx and XLS files using java
I have a large xlsx file, and I have to implement a large amount of data for search options. I have used Apache POI jar and JXL jar to search between rows and columns However, it takes a lot of time between a large amount of data. Some people can help me, that is, any jar file or any other concept can search faster in Excel files
String searchValue="my_value_to_search"; for (int i = 0; i < sheet.getColumns(); i++) { for (int j = 0; j < sheet.getRows(); j++) { value = sheet.getCell(i,j); valueType = value.getType(); String val=getCellType(valueType,value); if (val != null&&val==searchValue) { // To do manipulation. } } }
Solution
The bottleneck is usually the amount of memory required to represent large xlsx files in memory at a time (XLS can't be designed that large, which is usually not a problem) To search for a very large xlsx file without memory problems, you can do this:
>The xlsx file is actually a zip archive, and you can open it and read the contents as if it were a zip file. > The zip inside is the folder "XL / worksheet" and the file Sheet1 XML (and SHEET2. XML, etc.) > you can parse these XML files using a normal xmlreader (using callbacks for maximum performance and minimum memory consumption)
I hope it helps