//jxl read the excel file
package com.ms.jxltest;
import java.io.File;
import java.io.IOException;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class ReadTest {
public static void main(String [] args) throws BiffException, IOException{
Workbook book = Workbook.getWorkbook( new File("test.xls "));
// 获得第一个工作表对象
//Sheet sheet = book.getSheet( 0 );
Sheet[] sheets = book.getSheets();
for(Sheet sheet : sheets){
int columnum = sheet.getColumns(); // 得到列数
int rownum = sheet.getRows(); // 得到行数
System.out.println(columnum);
System.out.println(rownum);
for ( int i = 0 ; i < rownum; i ++ ) // 循环进行读写
{
for ( int j = 0 ; j < columnum; j ++ ) {
Cell cell1 = sheet.getCell(j, i);
String result = cell1.getContents();
System.out.print(result);
System.out.print( " \t " );
}
System.out.println();
}
}
book.close();
}
}