使用php在xls中保存Mysql数据
我想用PHP导出xls格式的数据。但不是下载信息,而是显示在我的网页上使用php在xls中保存Mysql数据,php,mysql,xls,Php,Mysql,Xls,我想用PHP导出xls格式的数据。但不是下载信息,而是显示在我的网页上 //connection to database //building of all information -> ($righe) header("Content-type: application/vnd.ms-excel"); header("Content-disposition: esporta_utenti.xls"); print $righe; exit(); $righe是我的元组 heade
//connection to database
//building of all information -> ($righe)
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: esporta_utenti.xls");
print $righe;
exit();
$righe
是我的元组
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Last-Modified: '.gmdate ('D, d M Y H:i:s', filemtime ($file_name)).' GMT');
header('Cache-Control: private',false);
header('Content-Type: '.$mime); // file mime type
header('Content-Disposition: attachment; filename="'.basename($file_name).'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize($file_name)); // provide file size
header('Connection: close');
readfile($file_name); // push it out
exit();
这段代码最初是在这里发布的。并可参考代码的详细解释。遵循适当的标题
标题('Content-Disposition:attachment;filename=“esporta_-tenti.xls”)代码>它不起作用,脚本的行为方式与您在header()
之前输出内容的方式相同。在标题之前注释所有代码,你会得到正确的答案。抱歉@JithinJose,但我不明白你在说什么。如果我在header()之前注释所有代码,$righe将为空