From 17f0d9e7ed2406a183a339b8bdd174ad7cf35090 Mon Sep 17 00:00:00 2001 From: "jipengfei.jpf" Date: Mon, 13 Aug 2018 10:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=89java=20model?= =?UTF-8?q?=E6=BC=8F=E5=88=97=E6=97=B6=E5=80=99=E7=BB=93=E6=9E=9C=E9=94=99?= =?UTF-8?q?=E4=B9=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../com/alibaba/excel/metadata/ExcelHeadProperty.java | 11 +++++++++++ .../read/modelbuild/ModelBuildEventListener.java | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d7adca1f..e004b369 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.alibaba easyexcel - 1.0.3 + 1.0.4-SNAPSHOT jar easyexcel easyexcel is a excel handle tools written in Java diff --git a/src/main/java/com/alibaba/excel/metadata/ExcelHeadProperty.java b/src/main/java/com/alibaba/excel/metadata/ExcelHeadProperty.java index c2ef3d8c..9a8508ec 100644 --- a/src/main/java/com/alibaba/excel/metadata/ExcelHeadProperty.java +++ b/src/main/java/com/alibaba/excel/metadata/ExcelHeadProperty.java @@ -137,6 +137,17 @@ public class ExcelHeadProperty { return excelColumnProperty; } + /** + * 根据Excel中的列号,获取Excel的表头信息 + * + * @param columnNum 列号 + * @return ExcelColumnProperty + */ + public ExcelColumnProperty getExcelColumnProperty1(int columnNum) { + return excelColumnPropertyMap1.get(columnNum); + + } + /** * 判断表头是否相同 * diff --git a/src/main/java/com/alibaba/excel/read/modelbuild/ModelBuildEventListener.java b/src/main/java/com/alibaba/excel/read/modelbuild/ModelBuildEventListener.java index c80d8b83..3a4b8dc9 100644 --- a/src/main/java/com/alibaba/excel/read/modelbuild/ModelBuildEventListener.java +++ b/src/main/java/com/alibaba/excel/read/modelbuild/ModelBuildEventListener.java @@ -43,7 +43,7 @@ public class ModelBuildEventListener extends AnalysisEventListener { } if (excelHeadProperty != null) { for (int i = 0; i < stringList.size(); i++) { - ExcelColumnProperty columnProperty = excelHeadProperty.getExcelColumnProperty(i); + ExcelColumnProperty columnProperty = excelHeadProperty.getExcelColumnProperty1(i); if (columnProperty != null) { Object value = TypeUtil.convert(stringList.get(i), columnProperty.getField(), columnProperty.getFormat(),context.use1904WindowDate());