JAVA: Reading Excel from POI

Source: Internet
Author: User

POI is an Apache open source jar package that can be found by searching the Java POI and downloading the development package.

Features that are included:

Can read excel2003,2007,2010 and so on.

To read the excel2007/2010 code:

 Public Static Booleanisnumeric (String str) { for(inti = 0; I < str.length (); i++) {        if(!Character.isdigit (Str.charat (i))) {            return false; }    }    return true;} Public StaticList<list<string>> readxlsx (String path)throwsException {InputStream is=NewFileInputStream (path); @SuppressWarnings ("Resource") Xssfworkbook Xssfworkbook=NewXssfworkbook (IS); List<List<String>> result =NewArraylist<>();  for(intSheetix = 0; Sheetix < Xssfworkbook.getnumberofsheets (); sheetix++) {Xssfsheet Xssfsheet=Xssfworkbook.getsheetat (Sheetix); if(Xssfsheet = =NULL)            Continue;  for(intRowNum = 1; RowNum <= xssfsheet.getlastrownum (); rownum++) {Xssfrow Xssfrow=Xssfsheet.getrow (RowNum); intMincolix =Xssfrow.getfirstcellnum (); intMaxcolix =Xssfrow.getlastcellnum (); List<String> rowlist =NewArraylist<>();  for(intColix = Mincolix; Colix < Maxcolix; colix++) {Xssfcell cell=Xssfrow.getcell (Colix); if(Cell = =NULL)                    Continue;            Rowlist.add (Cell.tostring ());        } result.add (Rowlist); }    }    returnresult;}

JAVA: Reading Excel from POI

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.