Browse Source

修复通用合并单元行最后一组数据未合并的bug

yzh 4 years ago
parent
commit
ea59d2ca65
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/Pxlswrite.php

+ 8 - 0
src/Pxlswrite.php

@@ -296,6 +296,14 @@ class Pxlswrite extends Excel
                 $count += count($item);
                 $this->push($_pushHandle, $count);
             }
+            //遍历到最后一行数据时,进行剩余还未合并单元行的单元行合并
+            foreach($cellKey as $c => $cell){
+                if($tempValue[$c]['count'] > 1){
+                    $startPosition = $cellMerge[$c][0];
+                    $endPosition = end($cellMerge[$c]);
+                    $this->mergeCells($startPosition . ':' . $endPosition, $tempValue[$c]['value'], $_mergeColumnStyle);
+                }
+            }
         } else {
             foreach (call_user_func($_generator) as $item) {
                 //循环逐行写入excel