2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Wraithmanilian
0

From what I read from the documentation, it looks like you have to add the rows in the sheet one at a time. Hence, from your code:

$xls = new Excel_XML('UTF-8', false, 'My Test Sheet');

$xls->addArray($data);
$xls->generateXML('my-test');

You could, as a SIMPLISTIC example:

$xls = new Excel_XML('UTF-8', false, 'My Test Sheet');
$myheaders = array('Data1','Data2','Data3');
$xls->addArray ( $myheaders );

// then sql call here
while($row = mysql_fetch_array($result, MYSQL_BOTH)) {
   $thisrow[0] = $row['dbvalue1'];
   $thisrow[1] = $row['dbvalue2'];
   $thisrow[2] = $row['dbvalue3'];
   $xls->addArray ( $thisrow );
}
$xls->generateXML('my-test');

This is just what makes sense to me after reading the docs. Basically, every time a new $xls->addArray is invoked, it is like a new line of data in the spreadsheet. Not tested, as I do not have the libraries installed. Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.