Morning,
I'm using the Spreadsheet_Excel_Writer to send data to a spreadsheet. Right now it's only pulling the headers not the data. It does write to the file and processes without errors but I cant seem to get the second group of data out. Any thoughts would be appreiciated.
Thanks
Laura
<?
// load the needed PEAR module
require_once 'pear/Spreadsheet/Excel/Writer.php';
// We give the path to our file here
$workbook = new Spreadsheet_Excel_Writer('H:\Excel\example.xls');
$worksheet =& $workbook->addWorksheet('My first worksheet');
// set row and column counts to zero
$num_row = 0;
$num_col = 0;
include ("connect.php");
/* construct and run our query */
$query = "SELECT *
FROM dbo.vwAcctIssue
where Department = 'mil'";
$row = mssql_query ($query);
$result = mssql_fetch_assoc ($row);
// set row and column counts to zero
$num_row = 0;
$num_col = 0;
// start parsing the query result
foreach ($result as $key=>$value) {
$worksheet->write($num_row,$num_col,$key);
$fields[$num_col] = $key;
$num_col++;
}
unset($num_col);
$num_row++;
foreach ($results['Department'] as $member_id=>$member)
{
//$num_col = 0;
foreach ($fields as $num_col=>$key)
{
$worksheet->write($num_row,$num_col,$member[$key]);
//$num_col++;
}
$num_row++;
}
// sending the file
$workbook->close();
?>