From db06fc50fd0632701dcbabb2193b01cba478c4fd Mon Sep 17 00:00:00 2001 From: "jipengfei.jpf" Date: Sat, 24 Feb 2018 15:43:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=8E=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E8=A1=8C=E6=A8=A1=E5=9E=8B=E8=BD=AC=E6=8D=A2=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/alibaba/excel/analysis/SaxAnalyserV07.java | 9 +++------ src/main/java/com/alibaba/excel/metadata/Sheet.java | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/alibaba/excel/analysis/SaxAnalyserV07.java b/src/main/java/com/alibaba/excel/analysis/SaxAnalyserV07.java index eec983b..b8a9b2d 100644 --- a/src/main/java/com/alibaba/excel/analysis/SaxAnalyserV07.java +++ b/src/main/java/com/alibaba/excel/analysis/SaxAnalyserV07.java @@ -33,7 +33,6 @@ import org.xml.sax.helpers.DefaultHandler; /** * @author jipengfei - * */ public class SaxAnalyserV07 extends BaseSaxAnalyser { @@ -67,7 +66,7 @@ public class SaxAnalyserV07 extends BaseSaxAnalyser { try { Sheet sheet = analysisContext.getCurrentSheet(); if (!isAnalysisAllSheets(sheet)) { - if (this.sheetSourceList.size() <= sheet.getSheetNo()) { + if (this.sheetSourceList.size() < sheet.getSheetNo() || sheet.getSheetNo() == 0) { return; } InputStream sheetInputStream = this.sheetSourceList.get(sheet.getSheetNo() - 1).getInputStream(); @@ -93,7 +92,7 @@ public class SaxAnalyserV07 extends BaseSaxAnalyser { if (sheet == null) { return true; } - if (sheet.getSheetNo() <= 0) { + if (sheet.getSheetNo() < 0) { return true; } return false; @@ -139,7 +138,6 @@ public class SaxAnalyserV07 extends BaseSaxAnalyser { return sheets; } - private void start() throws IOException, XmlException, ParserConfigurationException, SAXException { createTmpFile(); @@ -175,7 +173,7 @@ public class SaxAnalyserV07 extends BaseSaxAnalyser { if (attrs.getLocalName(i).toLowerCase(Locale.US).equals("name")) { name = attrs.getValue(i); } else if (attrs.getLocalName(i).toLowerCase(Locale.US).equals("r:id")) { - id = Integer.parseInt(attrs.getValue(i).replaceAll("rId","")); + id = Integer.parseInt(attrs.getValue(i).replaceAll("rId", "")); try { InputStream inputStream = new FileInputStream(XMLTempFile.getSheetFilePath(path, id)); sheetSourceList.add(new SheetSource(id, name, inputStream)); @@ -270,5 +268,4 @@ public class SaxAnalyserV07 extends BaseSaxAnalyser { } } - } diff --git a/src/main/java/com/alibaba/excel/metadata/Sheet.java b/src/main/java/com/alibaba/excel/metadata/Sheet.java index 8261997..2db84a0 100644 --- a/src/main/java/com/alibaba/excel/metadata/Sheet.java +++ b/src/main/java/com/alibaba/excel/metadata/Sheet.java @@ -15,7 +15,7 @@ public class Sheet { private int headLineMun; /** - * sheet序号 + * sheet序号 从0开始 */ private int sheetNo;