From 923aae75c5d7b2657c66686cd6c61a28f6bd3368 Mon Sep 17 00:00:00 2001 From: lxyer <237809796@qq.com> Date: Wed, 27 Mar 2019 17:20:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E4=B8=8A=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/lxyer/excel/poi/ExcelKit.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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) { + + } + }