From 29bb62d309edef5b4e2ec8112990a04761eeeb2b Mon Sep 17 00:00:00 2001 From: Raod <1130305001@qq.com> Date: Fri, 3 Sep 2021 14:40:57 +0800 Subject: [PATCH] =?UTF-8?q?fastjson=E6=B7=B1=E6=8B=B7=E8=B4=9D=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reportexcel/service/impl/ReportExcelServiceImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java index 879b024b..4238e208 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/reportexcel/service/impl/ReportExcelServiceImpl.java @@ -215,6 +215,8 @@ public class ReportExcelServiceImpl implements ReportExcelService { for (int i = 0; i < celldata.size(); i++) { //单元格对象 JSONObject cellObj = celldata.get(i); + //fastjson深拷贝问题 + String cellStr = cellObj.toJSONString(); //行号 Integer r = cellObj.getInteger("r"); @@ -246,10 +248,9 @@ public class ReportExcelServiceImpl implements ReportExcelService { String fieldLabel = addCell.getString(dataSet.getFieldLabel()); String replace = v.replace("#{".concat(dataSet.getSetCode()).concat(".").concat(dataSet.getFieldLabel()).concat("}"), fieldLabel); - JSONObject addCellData = new JSONObject(); - addCellData.putAll(cellObj); + //转字符串,解决深拷贝问题 + JSONObject addCellData = JSONObject.parseObject(cellStr); - addCellData.put("v", cellObj.getJSONObject("v")); addCellData.put("r", r + j); addCellData.put("c", c); addCellData.getJSONObject("v").put("v", replace);