Introduction to JAVA EXCEL APIs
Java Excel is an open source project through which Java developers can read the contents of Excel files, create new Excel files, and update existing Excel files. Using this API non-Windows operating systems can also work with Excel data tables through a pure Java application. Because it is written in Java, we can use the JSP, servlet to invoke the API to implement the access to Excel datasheet in the Web application.
application Example
Reading data tables from Excel files
The Java Excel API can read Excel data tables from either a file in the local file system (. xls) or from an input stream. The first step in reading an Excel datasheet is to create a workbook (term: Workbook), and the following code snippet illustrates what to do: you need to use an open source jar package, Jxl.jar. Download Address
File File = new file ("C:\\a.xls");
InputStream in = new FileInputStream (file);
Workbook workbook = Workbook.getworkbook (in);
Get the first sheet of Sheet table
Sheet Sheet = workbook.getsheet (0);
We can access it either through the name of the sheet or through the subscript. If you are accessing by subscript, note that the subscript starts at 0, just like an array.
//Get the first row, the value
of the first column Cell c00 = Rs.getcell (0, 0);
String strc00 = c00.getcontents ();
Gets the first row, the value of the second column
Cell c10 = Rs.getcell (1, 0);
String STRC10 = c10.getcontents ();
We can get the specified cell cell object by specifying the row and column cells
= Sheet.getcell (column, row);
You can also get all cell objects in a row or column
cell[] cells = sheet.getcolumn (column);
cell[] Cells2 = Sheet.getrow (row);
And then take the value of each cell.
String content = cell.getcontents ();
There are many other ways in this jar bag that need to be groped for yourself.