zend framework 数据集 excel 导出
小弟想把从数据库(mysql) 读取的数据集 excel格式导出
用的框架是zf 小弟是新手 求高手指导 谢谢你们!
------解决方案--------------------
class downloadcontroller extends controlloer{
function init(){}
function download(){
//查数据库代码取结果集
//结果写入文件aa.cvs
//header();下载
}
}
页面中 导出
大致就是这样。当然还有其他方法。
}
------解决方案--------------------
http://apps.hi.baidu.com/share/detail/35261920
------解决方案--------------------
php code header(content-type: application/vnd.ms-excel); header(content-disposition: attachment; filename=test.xls); header(pragma: no-cache); header(expires: 0); $title = mb_convert_encoding('推荐信息','gb2312','utf-8'); echo '
'; echo '' .$title. '
'; echo ''; if($recomtype == 'customer') { // 输出字段名 $zh = mb_convert_encoding('推荐人账号','gb2312','utf-8'); $xm = mb_convert_encoding('推荐人姓名','gb2312','utf-8'); $sj = mb_convert_encoding('推荐人手机号','gb2312','utf-8'); $bxm = mb_convert_encoding('被推荐人姓名','gb2312','utf-8'); $bsj = mb_convert_encoding('被推荐人手机号','gb2312','utf-8'); $bz = mb_convert_encoding('备注说明','gb2312','utf-8'); $time = mb_convert_encoding('推荐时间','gb2312','utf-8'); echo '' .$zh. ' '; echo '' .$xm. ' '; echo '' .$sj. ' '; echo '' .$bxm. ' '; echo '' .$bsj. ' '; echo '' .$bz. ' '; echo '' .$time. ' '; echo '
'; // 输出内容 foreach($allrecoms as $key => $outresult) { echo ''; echo ' ' . $outresult['khzh'] . ' '; echo '' . $outresult['khxm'] . ' '; echo '' . $outresult['sjhm'] . ' '; echo '' . $outresult['username'] . ' '; echo '' . $outresult['usernumber'] . ' '; echo '' . $outresult['usernote'] . ' '; echo '' . $outresult['recomtime'] . ' '; echo '
'; } echo '
';