Rumah  >  Artikel  >  pembangunan bahagian belakang  >  Zend Framework 数据集 excel 导出解决思路

Zend Framework 数据集 excel 导出解决思路

WBOY
WBOYasal
2016-06-13 13:39:121053semak imbas

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 ''; 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 ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // 输出内容 foreach($allRecoms as $key => $outResult) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
' .$title. '
' .$zh. '' .$xm. '' .$sj. '' .$bxm. '' .$bsj. '' .$bz. '' .$time. '
 ' . $outResult['KHZH'] . '' . $outResult['KHXM'] . '' . $outResult['SJHM'] . '' . $outResult['USERNAME'] . '' . $outResult['USERNUMBER'] . '' . $outResult['USERNOTE'] . '' . $outResult['RECOMTIME'] . '
';
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya: yii 怎么改变默认的控制器 Artikel seterusnya: 一个ajax的有关问题