David Gard
David Gard

Reputation: 12077

Loop through an excel range using a for loop

I am creating a *.xlsx document using PHPExcel, and I'm trying to loop through a load of cells in a range. I can split the cells to get the first and last in the range, but is it possible to loop through them using a PHP for loop? Thanks.

$first_cell = 'A4';
$last_cell = 'M4';

for(...) :

endfor;

Upvotes: 1

Views: 65

Answers (1)

SomeShinyObject
SomeShinyObject

Reputation: 7821

How about something like:

foreach (range('A','M') as $letter) {

    $current=$letter.'4'
    // where $current is the cell you are doing stuff to in the loop iteration
}

Upvotes: 2

Related Questions