-
I need to merge several cells, but they are defined as variables, how to write the code? There are always "PHP Parse error: syntax error, unexpected '":"' (T_CONSTANT_ENCAPSED_STRING), expecting ')' " for($i=0,$j=16; $i<count($boxFinalArr); $i++){
$boxCell = 'H'.$j;
$mergeStart1 = 'H'.$j;
$mergeStart2 = 'I'.$j;
$mergeStart3 = 'J'.$j;
$mergeStart4 = 'K'.$j;
$spreadsheet->getSheet(1)->fromArray($boxFinalArr[$i],NULL,$boxCell);
$j = $j + $boxIndexArr[$i];
$a = $j-1;
$mergeEnd1 = 'H'. $a;
$mergeEnd2 = 'I'. $a;
$mergeEnd3 = 'J'. $a;
$mergeEnd4 = 'K'. $a;
$spreadsheet->getSheet(1)->mergeCells($mergeStart1":"$mergeEnd1);
} |
Beta Was this translation helpful? Give feedback.
Answered by
Lydiachl
Oct 9, 2021
Replies: 1 comment
-
Problem solved: for($i=0,$j=16; $i<count($boxFinalArr); $i++){
$boxCell = 'H'.$j;
$mergeStart1 = 'H'.$j;
$mergeStart2 = 'I'.$j;
$mergeStart3 = 'J'.$j;
$mergeStart4 = 'K'.$j;
$spreadsheet->getSheet(1)->fromArray($boxFinalArr[$i],NULL,$boxCell);
$j = $j + $boxIndexArr[$i];
$a = $j-1;
$mergeEnd1 = 'H'. $a;
$mergeEnd2 = 'I'. $a;
$mergeEnd3 = 'J'. $a;
$mergeEnd4 = 'K'. $a;
$merge1 = $mergeStart1.':'.$mergeEnd1;
$merge2 = $mergeStart2.':'.$mergeEnd2;
$merge3 = $mergeStart3.':'.$mergeEnd3;
$merge4 = $mergeStart4.':'.$mergeEnd4;
$spreadsheet->getSheet(1)->mergeCells($merge1);
$spreadsheet->getSheet(1)->mergeCells($merge2);
$spreadsheet->getSheet(1)->mergeCells($merge3);
$spreadsheet->getSheet(1)->mergeCells($merge4);
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Lydiachl
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem solved: