From 39937610ef2f71f367721bff426209b28fad5e06 Mon Sep 17 00:00:00 2001 From: Jiaju Zhuang Date: Mon, 9 Sep 2019 20:42:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E8=A1=8C=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analysis/v07/handlers/ProcessResultCellHandler.java | 5 +++-- src/main/java/com/alibaba/excel/util/PositionUtils.java | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alibaba/excel/analysis/v07/handlers/ProcessResultCellHandler.java b/src/main/java/com/alibaba/excel/analysis/v07/handlers/ProcessResultCellHandler.java index 419d43e3..95816463 100644 --- a/src/main/java/com/alibaba/excel/analysis/v07/handlers/ProcessResultCellHandler.java +++ b/src/main/java/com/alibaba/excel/analysis/v07/handlers/ProcessResultCellHandler.java @@ -10,6 +10,7 @@ import com.alibaba.excel.constant.ExcelXmlConstants; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.read.listener.event.EachRowAnalysisFinishEvent; import com.alibaba.excel.read.metadata.holder.ReadRowHolder; +import com.alibaba.excel.util.PositionUtils; /** * Cell Handler @@ -32,8 +33,8 @@ public class ProcessResultCellHandler implements XlsxCellHandler { @Override public void startHandle(String name, Attributes attributes) { - analysisContext - .readRowHolder(new ReadRowHolder(Integer.valueOf(attributes.getValue(ExcelXmlConstants.POSITION)), + analysisContext.readRowHolder( + new ReadRowHolder(PositionUtils.getRowByRowTagt(attributes.getValue(ExcelXmlConstants.POSITION)), analysisContext.readSheetHolder().getGlobalConfiguration())); } diff --git a/src/main/java/com/alibaba/excel/util/PositionUtils.java b/src/main/java/com/alibaba/excel/util/PositionUtils.java index 090bbdfa..f135e473 100644 --- a/src/main/java/com/alibaba/excel/util/PositionUtils.java +++ b/src/main/java/com/alibaba/excel/util/PositionUtils.java @@ -7,6 +7,14 @@ public class PositionUtils { private PositionUtils() {} + public static int getRowByRowTagt(String rowTagt) { + int row = 0; + if (rowTagt != null) { + row = Integer.parseInt(rowTagt) - 1; + } + return row; + } + public static int getRow(String currentCellIndex) { int row = 0; if (currentCellIndex != null) {