问题描述
XSSFWorkbookxwb=newXSSFWorkbook(fileName);//循环工作表Sheetfor(intnumSheet=0;numSheet<xwb.getNumberOfSheets();numSheet++){XSSFSheetxSheet=xwb.getSheetAt(numSheet);if(xSheet==null){continue;}s//循环行Rowfor(introwNum=1;rowNum<=xSheet.getLastRowNum();rowNum++){XSSFRowxRow=xSheet.getRow(rowNum);if(xRow==null){continue;}//循环列CellString[]content=newString[xRow.getLastCellNum()];for(intcellNum=0;cellNum<=xRow.getLastCellNum();cellNum++){XSSFCellxCell=xRow.getCell(cellNum);if(xCell==null){continue;}if(xCell.getCellType()==XSSFCell.CELL_TYPE_BOOLEAN){content[cellNum]=xCell.getBooleanCellValue()+"";//content.append(xCell.getBooleanCellValue());}elseif(xCell.getCellType()==XSSFCell.CELL_TYPE_NUMERIC){content[cellNum]=xCell.getNumericCellValue()+"";//content.append(xCell.getNumericCellValue());}else{content[cellNum]=xCell.getStringCellValue();}}}}
解决方案
解决方案二:
通过这种方式初始化workbookFileInputStreamfis=newFileInputStream(fileName));XSSFWorkbookxwb=newXSSFWorkbook(fis);在finally中关闭fis就可以了
解决方案三:
好像不行啊,XSSFWorkbook不能给FileInputStream对象!