Excel file output load error

Hi All

I am currently creating a table and exporting this into excel. This worked fine although I have since upgraded to Excel 2010 and the spreadhseet is still created although when I try to open it in excel I got the following message

The file you are trying to open, ‘***.xls’, is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?

When I select “Yes” to the question the spreadhseet opens up fine. How can I stop the warning message from appearing in the first place?

Please find sample code below:


header("Content-type: application/vnd.ms-excel");
header("Content-type: application/x-msexcel");
header("Content-disposition: attachment; filename=text.xls");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html lang="en"><head></head><body>
<table>
<tr><td>Label 1</td><td>12</td></tr>
<tr><td>Label 12</td><td>24</td></tr>
</table>
</body></html>';

Many thanks
p_h_p

Thanks for your reply

Generate an actual Excel file:
http://phpexcel.codeplex.com/