From f315f2f94d7dab7e1b90f8c70b2dc324c594680c Mon Sep 17 00:00:00 2001
From: 林致杰 <1003392067@qq.com>
Date: 星期五, 29 七月 2022 17:01:59 +0800
Subject: [PATCH] 测试用例

---
 src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java |   49 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java b/src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java
index f03f3e5..ac49bee 100644
--- a/src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java
+++ b/src/main/java/com/ots/project/tool/report/MAQTR/chart/MAQTRChart.java
@@ -33,18 +33,63 @@
 
     public static void main(String[] args) throws IOException {
         try {
-            OutputStream os = new FileOutputStream("C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\鏋梍PAQ_IA_CN1.docx");
+/*            OutputStream os = new FileOutputStream("C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\鏋梍PAQ_IA_CN1.docx");
             XWPFDocument document = new XWPFDocument(POIXMLDocument.openPackage("C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\缁堢銆�0607涓枃鐗堛�慚AQ缁勫埆瀵规瘮鎶ュ憡.docx"));
 
             String fileName = "C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\MAQ缁勫埆瀵煎叆鏁版嵁妯℃澘.xlsx";
             //鍙樻洿鍥捐〃鏁版嵁
             changeMAQTRChart(document,fileName);
-            document.write(os);
+            document.write(os);*/
+            String fileName = "C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\缁勫埆瀵规瘮鎶ュ憡娴嬭瘯鏁版嵁.xlsx";
+            replaceContent(fileName);
         }catch (Exception e){
             e.printStackTrace();
         }
     }
 
+
+    /**
+     * 璁$畻鏁版嵁骞剁敓鎴愭ā鏉�
+     */
+    public static void replaceContent(String fileName){
+        try {
+            XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(fileName));
+            Map<String,Map<Integer,List<Double>>> dataMap = new HashMap<>();
+            for (int i = 0; i < wb.getNumberOfSheets(); i++) {
+                XSSFSheet sheet = wb.getSheetAt(i);
+                String companyName = sheet.getRow(1).getCell(0).getStringCellValue();
+                Map<Integer,List<Double>> map = new HashMap<>();
+                //琛�
+                for (int j = 1; j < sheet.getLastRowNum(); j++) {
+                    XSSFRow row = sheet.getRow(j);
+                    for (int k = 1; k < row.getLastCellNum(); k++) {
+                        XSSFCell cell = row.getCell(k);
+/*
+                        if (CellType.NUMERIC == cell.getCellType()) {
+                            System.out.println(cell.getNumericCellValue());
+                        } else if (CellType.STRING == cell.getCellType()) {
+                            System.out.println(cell.getStringCellValue());
+                        }
+*/
+                        //table1 澶氫釜绛旈缁撴灉澶勭悊
+                        if(map.get(k) != null){
+                            map.get(k).add(cell.getNumericCellValue());
+                        }else {
+                            List<Double> list = new ArrayList<>();
+                            list.add(cell.getNumericCellValue());
+                            map.put(k,list);
+                        }
+                    }
+                }
+                dataMap.put(companyName,map);
+            }
+            System.out.println(dataMap);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+    }
+
     /**
      * 鍒濆鍖栨姤鍛婃暟鎹�
      * @param fileName 鏁版嵁婧愭枃浠跺悕

--
Gitblit v1.9.1