Browse Source

技术资料附件接口优化

曹鹤洋 1 year ago
parent
commit
b923334923
1 changed files with 17 additions and 3 deletions
  1. 17 3
      application/api/controller/WorkOrder.php

+ 17 - 3
application/api/controller/WorkOrder.php

@@ -1689,11 +1689,25 @@ class WorkOrder extends Api
     {
         $fileName = '黄金叶(软大金圆)(二维码版)';
         $filePath = 'uploads/黄金叶(软大金圆)(二维码版).xlsx'; // Excel文件路径
+        $excelData = []; // 存储 Excel 数据的数组
 
         $spreadsheet = IOFactory::load($filePath);
-        $worksheet = $spreadsheet->getActiveSheet();
-        $data = $worksheet->toArray();
-
+        $sheet = $spreadsheet->getActiveSheet();
+        $highestRow = $sheet->getHighestRow();
+        $highestColumn = $sheet->getHighestColumn();
+        for ($row = 1; $row <= $highestRow; $row++) {
+            for ($col = 'A'; $col <= $highestColumn; $col++) {
+                $cellValue = $sheet->getCell($col . $row)->getValue();
+                $excelData[$row][$col] = $cellValue;
+            }
+        }
+        // 将 Excel 数据转换为 Luckysheet 格式的 JSON
+        // $data = [
+        //     'fileName' => $fileName,
+        //     'data' => $excelData,
+        // ];
+        $data = json_encode($excelData);
+        
         $this->success('成功', ['fileName'=>$fileName,'data'=>$data]);
     }
 }