Returning an Excel file from a PHP script
Jan.17, 2008 in
Tech
I needed to return an Excel file from a PHP script I wrote. The simplest way to do this is to create a page consisting of a single table and then setting the headers correctly. Excel will read the HTML table and convert it automatically into an excel spreadsheet – much easier than writing out a raw Excel file!
To do this, generate your HTML for the table and place it in a variable (don’t print it):
$html = "
| My column | My column 2 | ";
|---|

Leave a Reply