How to parse and get the data from an excel sheet

HaiI have this requirement of parsing an excel sheet and getting the data in it and storing the data in the appropriate tables in database.Please suggest me some way of doing this or the links wherein i can get some solution.Thanks in advance.........
[272 byte] By [kranthika] at [2007-11-27 9:43:45]
# 1
Take a look at the apache POI project at http://poi.apache.org/index.htmlIts a pure java library used to read/write excel files (and other microsoft formats such as word and so on).
sushika at 2007-7-12 23:49:33 > top of Java-index,Desktop,Developing for the Desktop...
# 2

/**

* Extract the content from the given Excel file. As a side effect the type is set too.

*

*/

public final static Reader getXLContent(final File f) {

Reader reader = null;

try {

CharArrayWriter writer = new CharArrayWriter();

POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(f));

HSSFWorkbook workbook = new HSSFWorkbook(fs);

for (int i = 0; i < workbook.getNumberOfSheets(); i++) {

HSSFSheet sheet = workbook.getSheetAt(i);

Iterator rows = sheet.rowIterator();

while (rows.hasNext()) {

HSSFRow row = (HSSFRow) rows.next();

Iterator cells = row.cellIterator();

while (cells.hasNext()) {

HSSFCell cell = (HSSFCell) cells.next();

switch (cell.getCellType()) {

case HSSFCell.CELL_TYPE_NUMERIC:

String num = Double.toString(cell.getNumericCellValue()).trim();

if (num.length() > 0) {

writer.write(num + " ");

}

break;

case HSSFCell.CELL_TYPE_STRING:

String text = cell.getStringCellValue().trim();

if (text.length() > 0) {

writer.write(text + " ");

}

break;

default: // skip

}

}

}

}

return new CharArrayReader(writer.toCharArray());

}

catch (Exception e) {

System.out.println("Exception in xls " + e.getClass());

}

return reader;

}

use poi 2.5 jar and use this code it will work fine

Regards

Madhu

myhoneya at 2007-7-12 23:49:33 > top of Java-index,Desktop,Developing for the Desktop...