Data in Array

Topics: User Forum
Dec 5, 2011 at 8:31 AM

Hi

I have my data in a array.  They are hunderts of rows, wiht 20 cols

$inhalt = array('ff','rtzt','zwrtzn')

$objPHPExcel->setActiveSheetIndex(0)->fromArray(array($inhalt),NULL,'A'.$rowNumber);

they go in each row, but in the same cell.

How can I separat the array in each cell?

Thanks

Granciela

 

Dec 6, 2011 at 7:52 AM

I'm still on the same problem

 

The dates are in $linie and with var_dump($linie); I get the right thing but I cant put it in cell  I tried a lot, and it does'nt work

one array:

string(214) "'Astrasse 28','EG','2','Liegenschaft','30.06.2001','offen',31.03.2011','offen','5','127','7','31','offen','2011','offen','676.00','214','8'"

 

The follow code says : Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\..\exp.\m_export.php on line 132

 

  $col = 'A';
    foreach($linie as $cell) {
       
       $objPHPExcel->setActiveSheetIndex(0)->setCellValue($col.$rowNumber,$cell);
       $col++;
    }
    $rowNumber++;


}

 

Dec 6, 2011 at 8:03 AM

according to your vardump, you are inserting a very long string, and not an array. Foreach expects an array, not a string. In your first example, you insert the array into an array, that is not necessary. 

Dec 6, 2011 at 9:06 AM

Thanks, I'm a little bit forder

 

But whitch is the right code?

---------------------

$furexcel = array();

while($row = mysql_fetch_array($result))
{
if (!empty($row['adresse'])){$furexcel['adresse'][]=$row['adresse'];}
if (!empt($row['stock'])){$furexcel['stock'][]=$row['stock'];}

}

----------------------------

$adresse= array();

$stock=array();

while($row = mysql_fetch_array($result))
{
if (!empty($row['adresse'])){$adresse[]=$row['adresse'];}
if (!empt($row['stock'])){$stock[]=$row['stock'];}

}

---------------------

$furexcel = array();

while($row = mysql_fetch_array($result))
{
if (!empty($row['adresse'])){$furexcel[][]=$row['adresse'];}
if (!empt($row['stock'])){$furexcel[][]=$row['stock'];}

}

----------------------------

when I got the file right, I hope the excel will come to