From 90d105bc3e585a5532d1a7873586603395188a40 Mon Sep 17 00:00:00 2001 From: Mr-wang Date: Thu, 27 Jul 2023 11:29:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zd/UpFileExcelAndPptController.java | 77 ++++++++++++------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/UpFileExcelAndPptController.java b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/UpFileExcelAndPptController.java index e1d5fc4f..5df95832 100644 --- a/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/UpFileExcelAndPptController.java +++ b/com.awspaas.user.apps.coe.pal.output.zd/src/com/awspaas/apps/coe/pal/output/zd/UpFileExcelAndPptController.java @@ -513,29 +513,49 @@ public class UpFileExcelAndPptController { XSLFTable tables = (XSLFTable) shape; XSLFTableRow firstRow = tables.getRows().get(1); - // 获取表格的第一行 - for (int i = 0; i < versionHistoryTable.size(); i++) { - JSONObject obj2 = versionHistoryTable.getJSONObject(i); - // 替换参数 - if (i==0){ - for (int col = 0; col < firstRow.getCells().size(); col++) { - XSLFTableCell cell = firstRow.getCells().get(col); - String text = cell.getText(); + if(versionHistoryTable.size()==1){ + JSONObject obj2 = versionHistoryTable.getJSONObject(0); + for (int col = 0; col < firstRow.getCells().size(); col++) { + XSLFTableCell cell = firstRow.getCells().get(col); + String text = cell.getText(); - text = text.replace("{{version}}", obj2.getString("P_versions")); - text = text.replace("{{company}}", obj2.getString("Issuing_department")); - text = text.replace("{{creauser}}", obj2.getString("Drafted_and_revised_by")); - text = text.replace("{{date}}", obj2.getString("Drafted_and_revised_date")); - text = text.replace("{{shen_user}}",obj2.getString("auditor") ); - text = text.replace("{{fuhe_user}}", obj2.getString("reviewer")); - text = text.replace("{{shenpi_user}}", obj2.getString("approver")); - text = text.replace("{{person}}", obj2.getString("Contents_and_reasons_for_revision")); - cell.setText(text); + text = text.replace("{{version}}", obj2.getString("P_versions")); + text = text.replace("{{company}}", obj2.getString("Issuing_department")); + text = text.replace("{{creauser}}", obj2.getString("Drafted_and_revised_by")); + text = text.replace("{{date}}", obj2.getString("Drafted_and_revised_date")); + text = text.replace("{{shen_user}}",obj2.getString("auditor") ); + text = text.replace("{{fuhe_user}}", obj2.getString("reviewer")); + text = text.replace("{{shenpi_user}}", obj2.getString("approver")); + text = text.replace("{{person}}", obj2.getString("Contents_and_reasons_for_revision")); + cell.setText(text); - } - }else { + } + }else { + + + JSONObject obj2 = versionHistoryTable.getJSONObject(0); + for (int col = 0; col < firstRow.getCells().size(); col++) { + XSLFTableCell cell = firstRow.getCells().get(col); + String text = cell.getText(); + + text = text.replace("{{version}}", obj2.getString("P_versions")); + text = text.replace("{{company}}", obj2.getString("Issuing_department")); + text = text.replace("{{creauser}}", obj2.getString("Drafted_and_revised_by")); + text = text.replace("{{date}}", obj2.getString("Drafted_and_revised_date")); + text = text.replace("{{shen_user}}",obj2.getString("auditor") ); + text = text.replace("{{fuhe_user}}", obj2.getString("reviewer")); + text = text.replace("{{shenpi_user}}", obj2.getString("approver")); + text = text.replace("{{person}}", obj2.getString("Contents_and_reasons_for_revision")); + cell.setText(text); + + } + + for (int i =1; i < versionHistoryTable.size(); i++) { + + JSONObject obj = versionHistoryTable.getJSONObject(i); + // 替换参数 XSLFTableRow newRow = table.addRow(); // 复制单元格 @@ -548,20 +568,21 @@ public class UpFileExcelAndPptController { XSLFTableCell cell = newRow.getCells().get(col); String text = cell.getText(); - text = text.replace("{{version}}", obj2.getString("P_versions")); - text = text.replace("{{company}}", obj2.getString("Issuing_department")); - text = text.replace("{{creauser}}", obj2.getString("Drafted_and_revised_by")); - text = text.replace("{{date}}", obj2.getString("Drafted_and_revised_date")); - text = text.replace("{{shen_user}}",obj2.getString("auditor") ); - text = text.replace("{{fuhe_user}}", obj2.getString("reviewer")); - text = text.replace("{{shenpi_user}}", obj2.getString("approver")); - text = text.replace("{{person}}", obj2.getString("Contents_and_reasons_for_revision")); + text = text.replace("{{version}}", obj.getString("P_versions")); + text = text.replace("{{company}}", obj.getString("Issuing_department")); + text = text.replace("{{creauser}}", obj.getString("Drafted_and_revised_by")); + text = text.replace("{{date}}", obj.getString("Drafted_and_revised_date")); + text = text.replace("{{shen_user}}",obj.getString("auditor") ); + text = text.replace("{{fuhe_user}}", obj.getString("reviewer")); + text = text.replace("{{shenpi_user}}", obj.getString("approver")); + text = text.replace("{{person}}", obj.getString("Contents_and_reasons_for_revision")); cell.setText(text); } - } + } } + // 获取表格的第一行 SDK.getLogAPI().consoleInfo("asddasdasdas"); } }