From 0b1cc38336692498e245a23a4effd0a430ea59b7 Mon Sep 17 00:00:00 2001 From: Wenyi Zhou Date: Thu, 27 Feb 2020 21:47:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BD=93Data=E6=98=AFLinkedL?= =?UTF-8?q?ist=E6=97=B6=EF=BC=8C=E9=9A=8F=E7=9D=80=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=87=8F=E5=A2=9E=E5=8A=A0=E6=80=A7=E8=83=BD=E5=8F=98=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 入参为List,当List是LinkedList时,get方法性能很差 --- .../alibaba/excel/write/executor/ExcelWriteAddExecutor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java index 5b0d8ae..a572fb7 100644 --- a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java +++ b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteAddExecutor.java @@ -46,9 +46,11 @@ public class ExcelWriteAddExecutor extends AbstractExcelWriteExecutor { } // BeanMap is out of order,so use fieldList List fieldList = new ArrayList(); - for (int relativeRowIndex = 0; relativeRowIndex < data.size(); relativeRowIndex++) { + int relativeRowIndex=0; + for(Object oneRowData : data){ int n = relativeRowIndex + newRowIndex; - addOneRowOfDataToExcel(data.get(relativeRowIndex), n, relativeRowIndex, fieldList); + addOneRowOfDataToExcel(oneRowData, n, relativeRowIndex, fieldList); + relativeRowIndex++; } }