java:读取Excel错误 10
publicclassMyExcel{publicstaticvoidreadExcel(){Sheetsheet;Workbookworkbook=null;Cellc...
public class MyExcel {
public static void readExcel(){
Sheet sheet;
Workbook workbook = null;
Cell cell1,cell2;
try {
workbook = Workbook.getWorkbook(new File("C:/Documents and Settings/test.xls"));
sheet = workbook.getSheet(1);
int i = 1;
cell1 = sheet.getCell(0,i);
cell2 = sheet.getCell(1,i);
while (!cell2.getContents().equals(null)){
if (cell1.getContents().compareTo("201403051051")>=0) {
System.out.println("学号:"+cell1.getContents()+" 姓名:"+cell2.getContents());
}
cell1 = sheet.getCell(0,i);
cell2 = sheet.getCell(1,i);
i++;
}
} catch (BiffException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
workbook.close();
}
public static void main(String[] args) {
readExcel();
}
}
我想要的结果已经出来了,但是最后抛出异常这是为什么? 展开
public static void readExcel(){
Sheet sheet;
Workbook workbook = null;
Cell cell1,cell2;
try {
workbook = Workbook.getWorkbook(new File("C:/Documents and Settings/test.xls"));
sheet = workbook.getSheet(1);
int i = 1;
cell1 = sheet.getCell(0,i);
cell2 = sheet.getCell(1,i);
while (!cell2.getContents().equals(null)){
if (cell1.getContents().compareTo("201403051051")>=0) {
System.out.println("学号:"+cell1.getContents()+" 姓名:"+cell2.getContents());
}
cell1 = sheet.getCell(0,i);
cell2 = sheet.getCell(1,i);
i++;
}
} catch (BiffException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
workbook.close();
}
public static void main(String[] args) {
readExcel();
}
}
我想要的结果已经出来了,但是最后抛出异常这是为什么? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询