Krokodile
Krokodile

Reputation: 115

Problems with column array (PHPExcel)

Sorry, I searched but didn't find any solution to my problem. I created an array that I want to export with PHPExcel, in one column (tableauBK):

if ($tableauBK[$k]<>"" && $tableauQ[$k]<>"")
    {
$tableauBL[$k]=$tableauBK[$k]*$tableauQ[$k];
    }

I can read the array without problems:

foreach ($tableauBL as $subtab)
{

    echo $subtab;
}

But I can't place the array in a column of my Excel file. I tried to make this code:

for ($row = 5; $row <= $highestRow; ++ $row) 
{
foreach ($tableauBL as $subtab)
{

    ->SetCellValue('A'.$row, $subtab)
}

But it doesn't work... I hope, you can help me.

Thank you in advance.

Krokodike.

Upvotes: 0

Views: 203

Answers (1)

Mark Baker
Mark Baker

Reputation: 212412

This is simply a case of PHP array handling

$row = 5;
foreach ($tableauBL as $subtab)
{
    $objPHPExcel->getActiveSheet()->SetCellValue('A'.$row++, $subtab);
}

or even simply

$objPHPExcel->getActiveSheet()->fromArray(array($tableauBL), null, 'A5');

Upvotes: 2

Related Questions