> Is there a way to output PHP to MS Excel format? > Send the headers for the appropriate application type and then format your output as HTML with Excel's styles. In order to get a feel for what my output should be, I just create a sample of what I want in Excel, save as html and then open the file in a text editor. Once you look at a few it's pretty easy to understand.
Here's a small example (okay, it is kind of long, but is probably helpful): <?php ////Code to execute a query, etc. my result identifier is $results header("Content-disposition: filename=$file_title.xls"); header("Content-type: application/vnd.ms-excel"); header("Pragma: no-cache"); header("Expires: 0"); ?> <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"> <head> <meta http-equiv=Content-Type content="text/html; charset=windows-1252"> <meta name=ProgId content=Excel.Sheet> <!-- STYLES --> <style id="Book1_29054_Styles"> <!-- //this is all swiped from excel, but I removed most of the content //--> <!--table {mso-displayed-decimal-separator:"\."; mso-displayed-thousand-separator:"\,";} .general {####BUNCH of STUFF####} .col_header {####BUNCH of STUFF####} .date {####BUNCH of STUFF####} //--> </style> </head> <body> <div id="Book1" align=center x:> <table x:str border=1 cellpadding=0 cellspacing=0 style='border-collapse:collapse;table-layout:fixed;border-color:#B71E00;'> <tr> <td colspan="4" class='col_header' align='center'><b><?php echo $title;?></b></td> </tr> <tr> <td class='col_header'>ID</td> <td class='col_header'>Email</td> <td class='col_header'>Visits</td> <td class='col_header'>Date Applied</td> </tr> <?php while ($row = $db->fetch_array($results)){ foreach($row as $key=>$val){ $$key = ($val == '')?' ':htmlentities(stripslashes($val),ENT_QUOTES); } printf ("<tr> <td class='general'>%d</td> <td class='general'>%s</td> <td class='general'>%d</td> <td class='date'>%s</td> </tr>\n",++$count, $email,$visits,$apply_date); } print "</table></div></body></html>"; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php