Passed
Push — master ( 4474a4...77f770 )
by ma
03:21
created
src/Excel/TWorkSheet.php 1 patch
Braces   +30 added lines, -19 removed lines patch added patch discarded remove patch
@@ -119,7 +119,10 @@  discard block
 block discarded – undo
119 119
         $this->fileTitle = [];
120 120
         $this->data = [];
121 121
         $this->field = [];
122
-        if($this->freezePane) $this->workSheet->freezePane($this->freezePane); //冻结窗格
122
+        if($this->freezePane) {
123
+            $this->workSheet->freezePane($this->freezePane);
124
+        }
125
+        //冻结窗格
123 126
     }
124 127
 
125 128
     /**
@@ -148,7 +151,7 @@  discard block
 block discarded – undo
148 151
             if (isset($fileTitle['mergeColumns'])) {
149 152
                 $this->mergeColumns = $fileTitle['mergeColumns'];
150 153
             }
151
-        }else{
154
+        } else{
152 155
             /**
153 156
              *  $fileTitle = [
154 157
              *       '姓名'=>'name',
@@ -159,7 +162,7 @@  discard block
 block discarded – undo
159 162
         // 根据字段映射方式处理 title
160 163
         if ($this->fieldMappingMethod === ConstCode::FIELD_MAPPING_METHOD_FIELD_CORRESPONDING_NAME) {
161 164
             $this->fileTitle = array_flip($titleData);// 字段对应名称方式 - 需要将键值对调
162
-        }else{
165
+        } else{
163 166
             $this->fileTitle = $titleData;// 名称对应字段方式 - 保持原样
164 167
         }
165 168
         $this->data = $data;
@@ -178,7 +181,7 @@  discard block
 block discarded – undo
178 181
                 foreach ($val as $k => $v){
179 182
                     $this->field[] = $v;
180 183
                 }
181
-            }else{
184
+            } else{
182 185
                 $this->field[] = $val;
183 186
             }
184 187
         }
@@ -210,7 +213,7 @@  discard block
 block discarded – undo
210 213
             if (!empty($this->mergeColumns)) {
211 214
                 $this->autoMergeColumns($rowStart, $this->_row - 1);
212 215
             }
213
-        }else{   //根据设置分组字段进行分组
216
+        } else{   //根据设置分组字段进行分组
214 217
             /** 数据分组 **/
215 218
             $data = [];
216 219
             $group_left_count = count($this->group_left);
@@ -225,13 +228,13 @@  discard block
 block discarded – undo
225 228
                     ];
226 229
                 }
227 230
                 $this->excelGroupLeft($data, $group_left_count);
228
-            }elseif($group_left_count == 2){
231
+            } elseif($group_left_count == 2){
229 232
                 foreach ($this->data as $v) {
230 233
                     $data[$v[$this->group_left[0]]][$v[$this->group_left[1]]][] = $v;
231 234
                 }
232 235
                 $this->data = $this->arrayCount($data);
233 236
                 $this->excelGroupLeft($this->data, $group_left_count);
234
-            }else{
237
+            } else{
235 238
                 throw new TinymengException(StatusCode::COMMON_PARAM_INVALID,
236 239
                     '左侧分组过多,导出失败!'
237 240
                 );
@@ -286,7 +289,7 @@  discard block
 block discarded – undo
286 289
                     $this->workSheet->setCellValue($this->cellName($_cols) . ($this->_row+1), $k);
287 290
                     if(!empty($this->titleWidth)) {
288 291
                         $this->workSheet->getColumnDimension($this->cellName($_cols))->setWidth($this->titleWidth); //列宽度
289
-                    }else{
292
+                    } else{
290 293
                         $this->workSheet->getColumnDimension($this->cellName($_cols))->setAutoSize(true); //自动计算宽度
291 294
                     }
292 295
                     if ($num < count($val)) {
@@ -304,7 +307,7 @@  discard block
 block discarded – undo
304 307
                 $this->workSheet->setCellValue($rowName . $this->_row, $key);//设置值
305 308
                 if(!empty($this->titleWidth)){
306 309
                     $this->workSheet->getColumnDimension($rowName)->setWidth($this->titleWidth); //列宽度
307
-                }else{
310
+                } else{
308 311
                     $this->workSheet->getColumnDimension($rowName)->setAutoSize(true); //自动计算宽度
309 312
                 }
310 313
             }
@@ -335,9 +338,9 @@  discard block
 block discarded – undo
335 338
                 for ($i=0;$i<count($v);$i++){
336 339
                     $content = $content[$v[$i]]??'';
337 340
                 }
338
-            }elseif($v == '_id'){
341
+            } elseif($v == '_id'){
339 342
                 $content = $this->_row-$this->title_row;//自增序号列
340
-            }else{
343
+            } else{
341 344
                 $content = ($val[$v]??'');
342 345
             }
343 346
             if(is_array($content) && isset($content['type']) && isset($content['content'])){
@@ -361,15 +364,15 @@  discard block
 block discarded – undo
361 364
                     $drawing->setCoordinates($rowName.$this->_row);
362 365
                     $drawing->setWorksheet($this->workSheet);
363 366
                 }
364
-            }else {
367
+            } else {
365 368
                 $content = $this->formatValue($content);//格式化数据
366 369
                 if (is_numeric($content)){
367 370
                     if($this->autoDataType && strlen($content)<11){
368 371
                         $this->workSheet->setCellValueExplicit($rowName.$this->_row, $content,DataType::TYPE_NUMERIC);
369
-                    }else{
372
+                    } else{
370 373
                         $this->workSheet->setCellValueExplicit($rowName.$this->_row, $content,DataType::TYPE_STRING2);
371 374
                     }
372
-                }else{
375
+                } else{
373 376
                     $this->workSheet->setCellValueExplicit($rowName.$this->_row, $content,DataType::TYPE_STRING2);
374 377
                 }
375 378
             }
@@ -411,7 +414,9 @@  discard block
 block discarded – undo
411 414
             if (!empty($this->mergeColumns)) {
412 415
                 foreach ($this->mergeColumns as $field) {
413 416
                     // 跳过分组字段本身
414
-                    if (in_array($field, $this->group_left)) continue;
417
+                    if (in_array($field, $this->group_left)) {
418
+                        continue;
419
+                    }
415 420
                     $colIdx = array_search($field, $this->field);
416 421
                     if ($colIdx !== false) {
417 422
                         $colLetter = $this->cellName($colIdx);
@@ -426,7 +431,7 @@  discard block
 block discarded – undo
426 431
                 foreach ($val['data'] as $dataRow){
427 432
                     $this->excelSetCellValue($dataRow);
428 433
                 }
429
-            }else{
434
+            } else{
430 435
                 $sub_group_start = $this->_row;
431 436
                 $rowName = $this->cellName($group_field_positions[1]); // 使用第二个分组字段的实际位置
432 437
                 
@@ -481,10 +486,14 @@  discard block
 block discarded – undo
481 486
      */
482 487
     private function autoMergeColumns($rowStart, $rowEnd)
483 488
     {
484
-        if ($rowEnd <= $rowStart) return;
489
+        if ($rowEnd <= $rowStart) {
490
+            return;
491
+        }
485 492
         foreach ($this->mergeColumns as $fieldName) {
486 493
             $colIdx = array_search($fieldName, $this->field);
487
-            if ($colIdx === false) continue;
494
+            if ($colIdx === false) {
495
+                continue;
496
+            }
488 497
             $colLetter = $this->cellName($colIdx);
489 498
             $lastValue = null;
490 499
             $mergeStart = $rowStart;
@@ -510,7 +519,9 @@  discard block
 block discarded – undo
510 519
      */
511 520
     private function applySheetStyle()
512 521
     {
513
-        if (empty($this->sheetStyle)) return;
522
+        if (empty($this->sheetStyle)) {
523
+            return;
524
+        }
514 525
         // 计算数据区范围
515 526
         $startCol = 'A';
516 527
         $endCol = $this->cellName(count($this->field) - 1);
Please login to merge, or discard this patch.