Skip to content

How to merge cells that are variables #2328

Answered by Lydiachl
Lydiachl asked this question in Q&A
Discussion options

You must be logged in to vote

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);
    

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Lydiachl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant