正如标题所指定的,我在下载文件时得到的文件没有指定的格式错误。以下是我的代码。此外,下载的文件没有任何单元格。
$content = ob_end_flush();
$filename = trim($filename);
$filename = str_replace(array(' ', '/', '\\'), '', $title);
$filename .= "_Export.xls";
header('Content-type: application/vnd.ms-excel; charset=utf-8');
//header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $content;
答案 0 :(得分:0)
放:
ob_clean();
ob_start();
前
header('Content-type: application/vnd.ms-excel; charset=utf-8');
并尝试...
或强>
变化
header('Content-type: application/vnd.ms-excel; charset=utf-8');
到
header('Content-type: application/msexcel; charset=utf-8');
或
header('Content-type: application/octet-stream; charset=utf-8');