As the title specifies, I get a File is not in specified format error when downloading the file. The following is my code. Also, the downloaded file does not have any cells.
正如标题所指定的那样,我在下载文件时得到的文件不是指定的格式错误。以下是我的代码。此外,下载的文件没有任何单元格。
$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;
1 个解决方案
#1
0
put:
ob_clean();
ob_start();
before
header('Content-type: application/vnd.ms-excel; charset=utf-8');
and try...
OR
change
header('Content-type: application/vnd.ms-excel; charset=utf-8');
to
header('Content-type: application/msexcel; charset=utf-8');
or
header('Content-type: application/octet-stream; charset=utf-8');
#1
0
put:
ob_clean();
ob_start();
before
header('Content-type: application/vnd.ms-excel; charset=utf-8');
and try...
OR
change
header('Content-type: application/vnd.ms-excel; charset=utf-8');
to
header('Content-type: application/msexcel; charset=utf-8');
or
header('Content-type: application/octet-stream; charset=utf-8');