From e2879f874d1b3388f61a17934fdae2d87d7f8167 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 24 Sep 2024 13:48:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(X-Pack):=20=E5=AE=9A=E6=97=B6=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E5=AF=BC=E5=87=BA=E8=A7=86=E5=9B=BEexcel=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E6=95=B0=E7=BB=84=E8=B6=8A=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/dataease/commons/utils/ExcelUtils.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/backend/src/main/java/io/dataease/commons/utils/ExcelUtils.java b/core/backend/src/main/java/io/dataease/commons/utils/ExcelUtils.java index dadd251f4e..d2bc35faaa 100644 --- a/core/backend/src/main/java/io/dataease/commons/utils/ExcelUtils.java +++ b/core/backend/src/main/java/io/dataease/commons/utils/ExcelUtils.java @@ -48,6 +48,11 @@ public class ExcelUtils { cellStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex()); cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + int fieldTypeSize = 0; + if (CollectionUtils.isNotEmpty(fieldTypes)) { + fieldTypeSize = fieldTypes.size(); + } + if (CollectionUtils.isNotEmpty(details)) { for (int i = 0; i < details.size(); i++) { Row row = curSheet.createRow(i); @@ -56,7 +61,7 @@ public class ExcelUtils { for (int j = 0; j < rowData.size(); j++) { Cell cell = row.createCell(j); // with DataType - if (i > 0 && (fieldTypes.get(j).equals(DeTypeConstants.DE_INT) || fieldTypes.get(j).equals(DeTypeConstants.DE_FLOAT)) && StringUtils.isNotEmpty(rowData.get(j))) { + if (i > 0 && j < fieldTypeSize && (fieldTypes.get(j).equals(DeTypeConstants.DE_INT) || fieldTypes.get(j).equals(DeTypeConstants.DE_FLOAT)) && StringUtils.isNotEmpty(rowData.get(j))) { cell.setCellValue(Double.valueOf(rowData.get(j))); } else { cell.setCellValue(rowData.get(j));