Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File 如何为xls文件提供保存选项_File_Download_For Loop_Xls - Fatal编程技术网

File 如何为xls文件提供保存选项

File 如何为xls文件提供保存选项,file,download,for-loop,xls,File,Download,For Loop,Xls,我需要生成一个xls格式的报表mysql表。我得到 这是一个代码,它的工作就像魅力。但问题是我需要有一个保存选项,下载并浏览目录来保存文件。有人能帮我吗?我试着换头球,但没有成功 提前谢谢 Vinay假设您使用的是PHP: header('Content-Type: application/vnd.ms-excel;'); header('Content-type: application/x-msexcel'); header('Content-Disposition: attachment

我需要生成一个xls格式的报表mysql表。我得到

这是一个代码,它的工作就像魅力。但问题是我需要有一个保存选项,下载并浏览目录来保存文件。有人能帮我吗?我试着换头球,但没有成功

提前谢谢


Vinay

假设您使用的是PHP:

header('Content-Type: application/vnd.ms-excel;');
header('Content-type: application/x-msexcel');
header('Content-Disposition: attachment; filename="your_xls_on_the_server.xls";');
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize('your_xls_on_the_server.xls'));
ob_clean();
flush();
readfile('your_xls_on_the_server.xls');
exit;