Java Read xlsx

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.