Increase columns in PHPExcel

1

I am using PHPExcel and I need to perform a For incrementing the column, For example:

for ($i = 'J'; $i <= 'J' + $num; $i++) { $objPHPExcel->setActiveSheetIndex(0) ->setCellValue($i . '11', $cabecera[$j]); $j++; }

$ header is an array with a variable number of elements and it is the texts that I want to print in the excel to generate and $ num is the number of elements that this arrangement has.

When executing the code I see that varibale $ i increases correctly. For $ num = 3 I should print up to column 'L', because I understand that : 'J' + $num = 'M' y 'L' < 'M'

However, the process does not leave For and continues to increase

Can anyone give me some guidance on how I can make this column increase according to the number of elements in an array?

    
asked by cmpasco 11.09.2017 в 18:49
source

1 answer

0

Try the following way understanding that 11 of the next line will never change value:

$objPHPExcel->setActiveSheetIndex(0)
             ->setCellValue($i . '11', $cabecera[$j]);

The code would be the following:

$column = 'J';
for ($i=0; $i<num; $i++) {
    $objPHPExcel->setActiveSheetIndex(0)
             ->setCellValue($column . '11', $cabecera[$i]);
    $column++;
}
    
answered by 11.09.2017 / 19:16
source