When reading a particularly large xlsx file, you need to use Streamingreader to control the JVM memory spikes within 200M
InputStream is =NewFileInputStream (NewFile (FilePath)); Streamingreader Reader=Streamingreader.builder (). Rowcachesize (10)//Number of rows to keep in memory (defaults to ten). buffersize (1024)//buffer size to use when reading InputStream to file (defaults to 1024x768). Sheetindex (0)//Index of sheet to use (defaults to 0). read (IS);//InputStream or file for XLSX file (required) for(Row r:reader) { for(Cell cell:r) {Switch(Cell.getcelltype ()) { CaseCell.CELL_TYPE_NUMERIC:System.out.print ("D" + cell.getnumericcellvalue () + "\ T"); Break; CaseCell.CELL_TYPE_STRING:System.out.print ("S" + cell.getstringcellvalue () + "\ T"); Break; CaseCell.CELL_TYPE_BOOLEAN:System.out.print ("B" + (Cell.getbooleancellvalue () + "\ T")); Break; }} System.out.print ("\ n");}
Https://github.com/monitorjbl/excel-streaming-reader
Compared to the official scheme
New File ("C:\\d\\data book.xlsx"=new Xssfworkbook (opcpackage);
The official program has a significantly higher memory footprint.
Java Read xlsx