jar包的下载地址:
http://sourceforge.net/projects/jexcelapi/files/jexcelapi/2.6.6/jexcelapi_2_6_6.zip/download
解析很简单,调用jxl里面的方法就好。
Workbook readwb = null;
try {
InputStream instream = new FileInputStream("E:/test.xls");
readwb = Workbook.getWorkbook(instream);
//获取Excel对应的sheet,从0开始
Sheet readsheet = readwb.getSheet(0);
//获取Sheet表中所包含的总列数和总行数
int rsColumns = readsheet.getColumns();
int rsRows = readsheet.getRows();
//获取指定单元格的对象引用
for (int i = 0; i < rsRows; i++)
{
for (int j = 0; j < rsColumns; j++)
{
Cell cell = readsheet.getCell(j, i);
System.out.print(cell.getContents() + " ");
}
System.out.println();
}
} catch (Exception e) {
// TODO: handle exception
}
}
注:1、每个单元格的位置认为是由一个二维坐标(i,j)给定,其中i表示列,j表示行,并且从上到下递增,从左到右递增。