Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.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
使用php在xls中保存Mysql数据_Php_Mysql_Xls - Fatal编程技术网

使用php在xls中保存Mysql数据

使用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

我想用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
是我的元组

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将为空