用的就是sample代码。$workbook = new Spreadsheet_Excel_Writer();
$workbook->send("test.xls");$worksheet =& $workbook->addWorksheet('My first worksheet');// The actual data
$worksheet->writeString(0, 0, 'Name');
$worksheet->writeString(0, 1, 'Age');
$worksheet->writeString(1, 0, 'John Smith');
$worksheet->writeString(1, 1, '30');
$worksheet->writeString(2, 0, 'Johann Schmidt');
$worksheet->writeString(2, 1, '31');
$worksheet->writeString(3, 0, 'Juan Herrera');
$worksheet->writeString(3, 1, '32');// Let's send the file
$workbook->close();但是下载下来的xls文件,打开以后是乱码。
但是如果是先生成本地文件。$workbook = new Spreadsheet_Excel_Writer("/tmp/test.xls");$worksheet =& $workbook->addWorksheet('My first worksheet');// The actual data
$worksheet->writeString(0, 0, 'Name');
$worksheet->writeString(0, 1, 'Age');
$worksheet->writeString(1, 0, 'John Smith');
$worksheet->writeString(1, 1, '30');
$worksheet->writeString(2, 0, 'Johann Schmidt');
$worksheet->writeString(2, 1, '31');
$worksheet->writeString(3, 0, 'Juan Herrera');
$worksheet->writeString(3, 1, '32');// Let's send the file
$workbook->close();用其他工具从服务器下载/tmp/test.xls。
能够打开,没有乱码。是怎么回事呢?
是不是跟header的content type设置有关?
找了很多网上的例子,修改header,还是没用。