Java reads excel and javaexcel

Source: Internet
Author: User

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

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.