请教使用jxl读取Excel的问题
import java.io.*;
import jxl.*;
public class TestExcel {
public static void main(String[] args) {
jxl.Workbook rwb = null;
Cell c = null;
try {
rwb = Workbook.getWorkbook(new File("test.xls"));
} catch (Exception e) {
System.err.println(e.getMessage());
}
try {
Sheet rs = rwb.getSheet(0);
int rsCols = rs.getColumns();
int rsRows = rs.getRows();
for (int x = 0 ; x<rsRows; x++) {
String strc = "";
for (int y = 0; y<rsCols; y++) {
c = rs.getCell(y,x);
strc = strc + c.getContents() + " ";
}
System.out.println(strc);
}
} catch(Exception ex) {
ex.printStackTrace();
}
rwb.close();
}
}
编译通过,运行时异常:
Unable to recognize OLE stream
java.lang.NullPointerException
at TestExcel1.main(TestExcel1.java:15)
Exception in thread "main" java.lang.NullPointe
at TestExcel1.main(TestExcel1.java:30)
请帮忙解决,谢谢
import jxl.*;
public class TestExcel {
public static void main(String[] args) {
jxl.Workbook rwb = null;
Cell c = null;
try {
rwb = Workbook.getWorkbook(new File("test.xls"));
} catch (Exception e) {
System.err.println(e.getMessage());
}
try {
Sheet rs = rwb.getSheet(0);
int rsCols = rs.getColumns();
int rsRows = rs.getRows();
for (int x = 0 ; x<rsRows; x++) {
String strc = "";
for (int y = 0; y<rsCols; y++) {
c = rs.getCell(y,x);
strc = strc + c.getContents() + " ";
}
System.out.println(strc);
}
} catch(Exception ex) {
ex.printStackTrace();
}
rwb.close();
}
}
编译通过,运行时异常:
Unable to recognize OLE stream
java.lang.NullPointerException
at TestExcel1.main(TestExcel1.java:15)
Exception in thread "main" java.lang.NullPointe
at TestExcel1.main(TestExcel1.java:30)
请帮忙解决,谢谢
...全文
相关推荐
java导入导出excel操作(jxl),整理中。。。
NULL 博文链接:https://virgoooos.iteye.com/blog/326007
jxl操作excel(2)
jxl操作excel文件的方法和一些注意事项
用jxl实现的读取excel(可以处理html格式的excel)
用jxl实现的读取excel文件,生成相应的对象集合。对于读取html格式的excel文件抛出的BiffException异常做了相应的处理
jxl包和它的使用方法
解压出来里面的jar包,参照https://blog.csdn.net/qq_40881680/article/details/82937532使用
通过JXL使用模板导出EXCEL
java版本通过JXL使用模板导出EXCEL


Web 开发
