package com.artron.test;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class ExcelRead {
/**
* @param args
*/
public static void main(String[] args) {
InputStream in = null;
Workbook workbook=null;
try {
// workbook = Workbook.getWorkbook(new File("c://test.xls"));
// workbook = Workbook.getWorkbook(in);
//in = new FileInputStream("c://test.xls");
in = new FileInputStream("c://222.xls");
workbook = Workbook.getWorkbook(in);
Sheet sheet=workbook.getSheet(0);
for (int i=0;i<sheet.getRows();i++)
{
Cell[] row = sheet.getRow(i);
for (int j=0;j<row.length;j++)
{
System.out.println(row[j].getContents()+"--type="+row[j].getType());
}
}
//Cell c2=sheet.getCell(1, 1);
//String cc=c2.getContents();
//System.out.println(cc);
} catch (BiffException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
workbook.close();
}
}
}