Of course, we aren't going to do any real conversion here. I looked into this, and it was just beyond what I wanted to do. The Excel file format(BIFF) has a documentation license from Microsoft, and going through all that is rediculous in comparison to what I'm about to show you.
This one line of code:
header ("Content-type: application/vnd.ms-excel");
followed by an HTML table, does just the trick.
The result:
- Internet Explorer starts Excel
- Netscape 4+ gives the option to open or save
Using .htaccess you can add on line of code, and then php will handle a .xls file extension, which will result in a .xls extension for your client system.
Add this line:
AddType application/x-httpd-php .xls
to the .htaccess file in your working directory. If it doesn't have on create it.