合并单元格导出
程序员文章站
2022-03-04 13:48:45
...
$num_arr = array_column($result,'order_num');
$arr = array_count_values($num_arr);
foreach ($arr as $kk=>$vv) {
if($vv>1){
$keys = array_keys($num_arr,$kk);
$end = $keys[count($keys)-1]+2;
$start = $end-$vv+1;
$objSheet->mergeCells('A'.$start.":".'A'.$end);
$objSheet->mergeCells('P'.$start.":".'P'.$end);
$objSheet->mergeCells('Q'.$start.":".'Q'.$end);
......
}
}
}