程序如下:
//读取Excel的类
import java.io.*;
import java.util.*;
import jxl.*;
import jxl.read.biff.BiffException;
public class ReadExcel{
public static void main(String[] args) {
try {
Workbook book = Workbook.getWorkbook(new File("1-1.xls"));
Sheet sheet = book.getSheet(0);
System.out.println("请输入要读取的单元格");
Scanner in = new Scanner(System.in);
int x = in.nextInt();
in = new Scanner(System.in);
int y = in.nextInt();
Cell cell1 = sheet.getCell(x,y);
String result = cell1.getContents();
System.out.println("Cell(x, y)" + " value : " + cell1.getContents() + "; type : " +
cell1.getType() );
book.close();
} catch (BiffException e) {
// TODO 自动生成 catch 块
System.out.println(e);
} catch (IOException e) {
// TODO 自动生成 catch 块
System.out.println(e);;
}
}
}
出现问题:
当读取一个单元格时,如果没自定义类型,则读取正确!!
当设定自定义类型 [红色][<60]0.0;[黑色]0.0 后,读取全部出错了。。。
哪位高手知道怎么回事啊?????