使用PHP从服务器下载Excel [英] Download Excel From Server Using PHP
本文介绍了使用PHP从服务器下载Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用 header
和 readfile
,但下载的文件已损坏。
// content type
header('Content-type:application / vnd.ms-excel');
//打开/保存对话框
header('Content-Disposition:attachment; filename ='。$ fileName);
//从服务器读取并写入缓冲区
readfile($ reportPath);
任何人都可以帮助我最好的方式从服务器下载现有的Excel文件。
下载后请看下面的数据图像
解决方案
ob_clean();
将该代码放在所有标题声明之前
Can anyone help me to write code on PHP to download Excel File from the server.
I have created below codes using header
and readfile
but the downloaded file was corrupted.
//content type
header('Content-type: application/vnd.ms-excel');
//open/save dialog box
header('Content-Disposition: attachment; filename='.$fileName);
//read from server and write to buffer
readfile($reportPath);
Can anyone help me on the best way to download existing Excel file from the server.
Please see below image of data after downloaded
解决方案
ob_clean();
put that code before all header declaration
这篇关于使用PHP从服务器下载Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文