diff --git a/src/com/lxyer/excel/poi/ExcelKit.java b/src/com/lxyer/excel/poi/ExcelKit.java index 7b5765f..ece7363 100644 --- a/src/com/lxyer/excel/poi/ExcelKit.java +++ b/src/com/lxyer/excel/poi/ExcelKit.java @@ -235,9 +235,9 @@ public class ExcelKit { List maps = readExcel(sheet, fields, lastRowNum); //move head - if (lastRowNum < 0 && maps.size() > 0) { + /*if (lastRowNum < 0 && maps.size() > 0) { maps.remove(0); - } + }*/ data.put(sheet.getSheetName(), maps); } return data; @@ -358,13 +358,27 @@ public class ExcelKit { private static Workbook getWorkbook(File file) throws IOException { Workbook wk; + FileInputStream fis = new FileInputStream(file); try { - wk = new HSSFWorkbook(new FileInputStream(file));//if excel version 2007+ will throws OfficeXmlFileException + wk = new HSSFWorkbook(fis);//if excel version 2007+ will throws OfficeXmlFileException } catch (OfficeXmlFileException e) { - wk = new XSSFWorkbook(new FileInputStream(file)); + wk = new XSSFWorkbook(fis); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (Exception e) { + //e.printStackTrace(); + } + } } return wk; } + //dev + public void setWorkbook(File file) { + + } + }