garian_of_brunlea Posted March 20, 2007 Share Posted March 20, 2007 Hiya This is the code I use for PHP/MySQL on another site and it works great, but this new site I am working on is PHP/MSSQL and I cannot get the export to Excel to work. MySQL Method (how can I change this to work with MSSQL) while($row = mysql_fetch_row($glRes)){ $line = ''; foreach($row as $value){ if(!isset($value) || $value == ""){ $value = "\t"; }else{ $value = str_replace('"', '""', $value); $value = '"' . $value . '"' . "\t"; } $line .= $value; } $data .= trim($line)."\n"; } $data = str_replace("\r", "", $data); if ($data == "") { $data = "\no matching records found\n"; } header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=report.xls"); header("Pragma: no-cache"); header("Expires: 0"); echo $header."\n".$data; Link to comment https://forums.phpfreaks.com/topic/43559-help-export-recordset-to-ms-excel-from-phpmssql/ Share on other sites More sharing options...
Caesar Posted March 20, 2007 Share Posted March 20, 2007 I take it you've changed your connection string right? Because right off the bat, you need to be using mssql_fetch_row, instead. Link to comment https://forums.phpfreaks.com/topic/43559-help-export-recordset-to-ms-excel-from-phpmssql/#findComment-211608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.