Zend Framework 数据集 excel 导出
小弟想把从数据库(mysql) 读取的数据集 excel格式导出
用的框架是ZF 小弟是新手 求高手指导 谢谢你们!
[解决办法]
class downloadController extends Controlloer{
function init(){}
function download(){
//查数据库代码取结果集
//结果写入文件aa.cvs
//header("");下载
}
}
页面中 <a href="<?=$server;?>/download/download">导出</a>
大致就是这样。当然还有其他方法。
}
[解决办法]
http://apps.hi.baidu.com/share/detail/35261920
[解决办法]
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 '<table border="1" cellspacing="2" cellpadding="2" width="50%" align="center">'; echo '<tr bgcolor="0xCCCCCC"><td colspan="5" align="center">' .$title. '</td></tr>'; echo '<tr bgcolor="0xCCCCCC" height="50%">'; 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 '<td>' .$zh. '</td>'; echo '<td>' .$xm. '</td>'; echo '<td>' .$sj. '</td>'; echo '<td>' .$bxm. '</td>'; echo '<td>' .$bsj. '</td>'; echo '<td>' .$bz. '</td>'; echo '<td>' .$time. '</td>'; echo '</tr>'; // 输出内容 foreach($allRecoms as $key => $outResult) { echo '<tr>'; echo '<td> ' . $outResult['KHZH'] . '</td>'; echo '<td>' . $outResult['KHXM'] . '</td>'; echo '<td>' . $outResult['SJHM'] . '</td>'; echo '<td>' . $outResult['USERNAME'] . '</td>'; echo '<td>' . $outResult['USERNUMBER'] . '</td>'; echo '<td>' . $outResult['USERNOTE'] . '</td>'; echo '<td>' . $outResult['RECOMTIME'] . '</td>'; echo '</tr>'; } echo '</table>';