I need to read large excel files and import their data into my application.
Since the POI processes a large number of heaps for work, often throwing OutOfMemory errors, I found that there is a Streaming API for processing excel data in a serial way (and not for downloading a file completely to memory)
I created an xlsx workbook with one worksheet and typed several values ββin the cells and came up with the following code to try reading it:
public static void main(String[] args) throws Throwable { SXSSFWorkbook wb = new SXSSFWorkbook(new XSSFWorkbook(new FileInputStream("C:\\test\\tst.xlsx")));
However, despite the fact that it correctly receives its worksheets, it always contains empty (zero) lines.
I have researched and learned some examples of Streaming APIs on the Internet, but none of them contain reading existing files, they are all designed to create excel files.
Is it possible to read data from existing .xlsx files in a stream?
source share