java操作xls
File file = new File(fileName1.toString().trim());
rwb = Workbook.getWorkbook(file);
这两行代码想要获取一个xls对象.调试之后,file没错的,但是调试到第二行的时候rwb一直为null...不理解?请大家帮忙
[解决办法]
FileInputStream fis = new FileInputStream("F://data/1.xls");
HSSFWorkbook workBook = new HSSFWorkbook(fis);
[解决办法]
Workbook xlsWorkbook = null;
InputStream is = null;
if(fileFileName.toUpperCase().endsWith(".XLS")) {
is = org.apache.commons.io.FileUtils.openInputStream(file);
xlsWorkbook = Workbook.getWorkbook(is);}
[解决办法]
你要先判断xml中的元素是否存在,再进行解析,呵呵,我刚在做这样的项目,你要是想要代码的话,我可以给你参考噢~~~