package javatest1014;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
public class ReadExcel{
public static void main(String[] args){
jxl.Workbook workbook=getWorkBook();
jxl.Sheet sheet=workbook.getSheet(0);
jxl.Cell cell= sheet.getCell(0, 6);
System.out.println(cell.getContents());
System.out.println(cell.getRow());
System.out.println(cell.getColumn());
System.out.println(cell.getType());
System.out.println(sheet.getColumns());
System.out.println(sheet.getRows());
int rows=sheet.getRows();//遍历 只能用数组
int columns=sheet.getColumns();
int i=0;
try{
while(i<columns){
jxl.Cell[] cell00=sheet.getColumn(i);
for(int j=0;j<rows;j++){
System.out.println(cell00[j].getContents());
}
i++;
}
}catch(Exception e){
e.printStackTrace();
}
}
/*
* get filePath
*/
public static String getPath(){
String FilePath="E://data_checkout";
String FileName="LAT.xls";
FileName=FilePath+"//"+FileName;
return FileName;
}
/*
* create WorkBook Object
*/
public static jxl.Workbook getWorkBook(){
InputStream is=null;
jxl.Workbook wk=null;
try{
File file=new File(getPath());
if(!file.exists()) file.createNewFile();
is=new FileInputStream(file);
wk=jxl.Workbook.getWorkbook(is);
System.out.println("get WorkBook is successful !");
}catch(Exception e){
e.printStackTrace();
}
return wk;
}
}