Java Read Excel file

Source: Internet
Author: User

Operation Steps:

1. First to the online download Jexcelapi rar package, the latest is: Jexcelapi_2_6_12.tar, and then unpack it, copy the Jxl.jar file to the Web-inf\lib directory or directly into the Java project
2. The corresponding operation code is as follows:

 Packagecom.xqh.java.test; ImportJava.io.File; Importjava.io.IOException; ImportJXL.  Cell; ImportJXL.  Sheet; ImportJXL.  Workbook; Importjxl.read.biff.BiffException;  Public classJavareadexcel { Public Static voidMain (string[] args) {Try{String FileName= "?:\ \...\\xxx.xlsx ";//path to Excel fileFile File =NewFile (FileName);//To create a file objectWorkbook WB = workbook.getworkbook (file);//get an Excel Workspace object from a file stream (WorkBook)Sheet Sheet = wb.getsheet (0);//get page from workspace (Sheet)                           for(inti = 0; I < sheet.getrows (); i++) {//Loop through the contents of an Excel table                 for(intj = 0; J < Sheet.getcolumns (); J + +) {cell cell=Sheet.getcell (J, I);                  System.out.println (Cell.getcontents ());              } System.out.println (); }          } Catch(biffexception e) {e.printstacktrace (); } Catch(IOException e) {e.printstacktrace (); }                }  }  

This article transferred from: http://blog.csdn.net/tkd03072010/article/details/6692366

Java Read Excel file

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.