From 32d4ad3cd7543a62a75646cc4ed96f7da57283d8 Mon Sep 17 00:00:00 2001 From: duandongmei Date: Tue, 29 Jan 2019 09:20:33 +0600 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=A4=84=E7=90=86=E6=97=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E5=8D=95=E5=85=83=E6=A0=BC=EF=BC=8C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=89=80=E6=9C=89=E6=9C=89=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E5=8D=95=E5=85=83=E6=A0=BC=E5=8F=8A=E4=B8=8B=E6=A0=87?= =?UTF-8?q?=EF=BC=8C=E6=9C=80=E5=90=8E=E5=B0=86=E6=97=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=B9=E6=8D=AE=E4=B8=8B?= =?UTF-8?q?=E6=A0=87=E8=A1=A5=E5=85=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nis/util/excel/XLSXCovertCSVReader.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/nis/util/excel/XLSXCovertCSVReader.java b/src/main/java/com/nis/util/excel/XLSXCovertCSVReader.java index 4c195e4ee..79f66204b 100644 --- a/src/main/java/com/nis/util/excel/XLSXCovertCSVReader.java +++ b/src/main/java/com/nis/util/excel/XLSXCovertCSVReader.java @@ -8,7 +8,9 @@ import java.sql.SQLException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; @@ -32,6 +34,8 @@ import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; +import com.nis.util.StringUtil; + /** * 使用CVS模式解决XLSX文件,可以有效解决用户模式内存溢出的问题 @@ -102,6 +106,7 @@ public abstract class XLSXCovertCSVReader { // The last column printed to the output stream private int lastColumnNumber = -1; private List rowlist = new ArrayList(); + private Map rowMap = new HashMap(); // Gathers characters as they are seen. private StringBuffer value; // private String[] record; @@ -128,6 +133,7 @@ public abstract class XLSXCovertCSVReader { this.nextDataType = xssfDataType.NUMBER; this.formatter = new DataFormatter(); rowlist.clear();// 每次读取都清空行集合 + rowMap.clear(); } /* @@ -286,7 +292,8 @@ public abstract class XLSXCovertCSVReader { if(!refnum.equals(preRefnum)){ int len = countNullCell(refnum, preRefnum); for(int i=0;i tempList=new ArrayList<>(totalLen); - for(int i=0;i<(totalLen-rowlist.size());i++) { - tempList.add(""); + //修改某一个单元格为空,字段映射顺序错乱问题 + for(int i=0;i