Java reads excel and javaexcel
Read excel in java
Java excel api: it is an open-source project. Java developers can read the content of an Excel file, create a new Excel file, and update an existing Excel file. Using this API, non-Windows operating systems can also use Java-only applications to process Excel Data Tables. Because it is written in Java, we can use JSP and Servlet in Web applications to call APIs to access Excel Data Tables.
Download:
The jar package of Java Excel API can be obtained through the following URL:
Http://sourceforge.net/projects/jexcelapi/files/jexcelapi/2.6.6/jexcelapi_2_6_6.zip/download
(Including all versions): http://sourceforge.net/projects/jexcelapi/files/
Directly (create a task on thunder ):
Http://nchc.dl.sourceforge.net/project/jexcelapi/jexcelapi/2.6.6/jexcelapi_2_6_6.zip
Note: jexcelapi_2_6_6 cannot read excel 2007 files (*. xlsx ). Excel 2003 (*. xls) is supported only ).
Code:
1 package excelOperation2; 2 3 import java. io. file; 4 import java. io. fileNotFoundException; 5 import java. util. required; 6 7 import jxl. cell; 8 import jxl. sheet; 9 import jxl. workbook; 10 11 public class testMain {12 13 public static void main (String [] args) {14 // TODO Auto-generated method stub15 try {16 File file = new File ("myRes // a.xls"); // create a File object 17 Workbook wb = Workbook. getWorkbook (file); // obtain the Excel Workspace object (WorkBook) 18 Sheet sheet = wb from the file stream. getSheet (0); // get the page (Sheet) 19 for (int I = 0; I <sheet. getRows (); I ++) {// print the content in the Excel table cyclically 20 for (int j = 0; j <sheet. getColumns (); j ++) {21 Cell cell = sheet. getCell (j, I); 22 System. out. printf (cell. getContents () + ""); 23} 24 System. out. println (); 25} 26} catch (Exception e) {27 e. printStackTrace (); 28} 29} 30 31}
Excel Data:
Console printing:
Directory structure:
For more detailed operations, go:
JAVA Excel files-KeeneWoo-blog Park http://www.cnblogs.com/wuxinrui/archive/2011/03/20/1989326.html