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