第1个回答 2011-08-13
CI框架:
前台:a.php <a href="download/export">download</a>
后台:download.php
function export(){
//把js,css的路径文件名填充下面的$url和$fname就可以了
//至于html文件,先在后台生成一个html文件,然后下载就可以了
$fname=date('YmdHis').'.xls';
$url='./xls/'.$fname;
$this->excel_m->write($url);
$file = fopen($url,"r"); // 打开文件
// 输入文件标签
header('Content-Encoding: utf-8');
header("Content-type: application/octet-stream");
header("Accept-Ranges: bytes");
header("Accept-Length: ".filesize($url));
header('Content-Transfer-Encoding: binary' );
header("Content-Disposition: attachment; filename=" .$fname); //以真实文件名提供给浏览器下载
header('Pragma: no-cache');
header('Expires: 0');
//输出文件内容
echo fread($file,filesize($url));
fclose($file);
}本回答被提问者和网友采纳