PHP 弹出保存对话框 php对话框excel 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.cnblogs.com/zcy_soft/archive/2011/06/09/2076728.html 这个完全与我的需求不对,而且,我的需求是:点击【导出为Excel】 直接弹出路径选择框,或者是直接下载也行,但是要浏览器端下载 header("Content-type:application/vnd.ms-excel");header("Content-Disposition:filename=php2excel.xls");echo iconv("UTF-8", "GBK", "姓名") . "\t" . iconv("UTF-8", "GBK", "性别") . "\n";foreach ($get as $key => $value) {echo iconv("UTF-8", "GBK", $value["username"]) . "\t" . iconv("UTF-8", "GBK", $value["sex"]) . "\n";} 可以具体一点么?因为我是需要后台再去查询数据库,然后据所得的内容填充到EXCEL。 我仔细询问了多个PHPer 目前应该是做不到弹出路径选择框,只能退而求其次,显示为下载模样,代码稍后给大家贴出。敬谢! 赞同,要是这样你就还要考虑如果用户不是用windows呢? $objWriter->save( $fileName ); download( $fileName, true,false ); //exit();function download( $fileName, $delDesFile = false, $isExit = true ) { if ( file_exists( $fileName ) ) { header( 'Content-Description: File Transfer' ); header( 'Content-Type: application/octet-stream' ); header( 'Content-Disposition: attachment;filename = ' . basename( $fileName ) ); header( 'Content-Transfer-Encoding: binary' ); header( 'Expires: 0' ); header( 'Cache-Control: must-revalidate, post-check = 0, pre-check = 0' ); header( 'Pragma: public' ); header( 'Content-Length: ' . filesize( $fileName ) ); ob_clean(); flush(); readfile( $fileName ); if ( $delDesFile ) { unlink( $fileName ); } if ( $isExit ) { exit; } } } 这是我最终的方案。 php 上传 安全??? 用手机输入后出现乱码 请教WAP开发中的乱码问题 php是怎么样一门语言? 关于初学者应该怎么选择php工具 写PHP1年多,接下去我该怎么办? mysql版本的感慨 submit后以指定宽度、有垂直滚动条打开新窗口显示结果? Parse error: parse error, unexpected $ 是怎么回事? 给我们接口地址,该怎么写呢 web还没学好,同时看点http协议可以不? 伪静态说的个什么东东
这个完全与我的需求不对,而且,我的需求是:点击【导出为Excel】 直接弹出路径选择框,
或者是直接下载也行,但是要浏览器端下载
header("Content-Disposition:filename=php2excel.xls");
echo iconv("UTF-8", "GBK", "姓名") . "\t" . iconv("UTF-8", "GBK", "性别") . "\n";
foreach ($get as $key => $value) {
echo iconv("UTF-8", "GBK", $value["username"]) . "\t" . iconv("UTF-8", "GBK", $value["sex"]) . "\n";
}
download( $fileName, true,false );
//exit();
function download( $fileName, $delDesFile = false, $isExit = true ) {
if ( file_exists( $fileName ) ) {
header( 'Content-Description: File Transfer' );
header( 'Content-Type: application/octet-stream' );
header( 'Content-Disposition: attachment;filename = ' . basename( $fileName ) );
header( 'Content-Transfer-Encoding: binary' );
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, post-check = 0, pre-check = 0' );
header( 'Pragma: public' );
header( 'Content-Length: ' . filesize( $fileName ) );
ob_clean();
flush();
readfile( $fileName );
if ( $delDesFile ) {
unlink( $fileName );
}
if ( $isExit ) {
exit;
}
}
} 这是我最终的方案。