Howdy all! Some of my users want Excel reports from MySQL databases, so I have done the following with PHP;
<!--BEGIN CODE--> <? header("Content-Type: application/x-excel"); header("Content-Disposition: inline; filename=\"excel.xls\""); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); //connect to and select database if(!($dbconnect = mysql_pconnect("127.0.0.1", "user", "password"))){ print("Failed to connect to database!\n"); exit(); } if(!mysql_select_db("rcr", $dbconnect)){ print("Failed to select database!\n"); exit(); } //query $qrecord = "SELECT DISTINCT RecordID "; $qrecord .= "FROM tblClass10 "; ?> <table> <tr> <td></td> <? while($dbrow = mysql_fetch_object($dbrecord)){ print("<td>"); print($dbrow->RecordID); print("</td>\n"); } ?> </tr> </table> <!--END CODE--> If I name the file with a .xls extension it displays the code in the excel worksheet in the browser. If I name the file with the .php extension it opens Excel seperately, gives me a file download option (I click 'Open') and then asks me to tell it what created the file, so I pick Excel. Then the data is displayed properly in the Excel worksheet, outside of the browser. I want the file to open an Excel worksheet in the browser (IE, on an Intranet). Is there something I am missing? Thanks! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php