单击链接时如何在php中以excel格式保存所选数据?我想将文件保存在文件运行时给出的位置?请指教我..
header('Content-Type: application/vnd.ms-excel'); //define header info for browser
header('Content-Disposition: attachment;
filename='.$dbTable.'-'.date('Ymd').'.xls');
header('Pragma: no-cache');
header('Expires: 0');
答案 0 :(得分:0)
试试这个:
header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
header("Content-Disposition: inline; filename=\"" . $dbTable.'-'.date('Ymd') . ".xls\"");
header("Pragma: no-cache");
header("Expires: 0");
或者简单地说:
header("Location: http://path/to/file/filename.xlsx");
/* Make sure that code below does not get executed when we redirect. */
exit;