PHP创建Excel文件,变音符问题
Hello I am creating a Excel file with PHP. I am setting the header, before I print out some data:
header('Content-type: application/vnd.ms-excel; charset=utf-8');
And then I am inserting something like:
echo '<table><tr><td>täääst</td></tr></table>';
My problem is that the ä isn't shown right in the excel file.
I am also having an error, when I open the file that says:
The file you are trying to open, 'filename.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?
Can you help me please? Thank you in advance.
You're not creating an excel file. You're creating an HTML file and telling excel to pretend it's an .xls. That's why you're getting the "different format" warning.
Use PHPExcel to create a native excel file (.xls or .xlsx).