工作中做导出的时候,需要导出自定义的表格或嫌弃导出的excel格式太难看了。
需要设置颜色、字号大小、加粗、合并单元格等等。
效果图:
php代码:/**
* 导出文件
* @return string
*/
public function export()
{
$file_name = 成绩单-.date(y-m-d h:i:s,time());
$file_suffix = xls;
header(content-type: application/vnd.ms-excel);
header(content-disposition: attachment; filename=$file_name.$file_suffix);
//根据业务,自己进行模板赋值。
$this->display();
}html代码:xmlns:x=urn:schemas-microsoft-com:office:excel
xmlns=http://www.w3.org/tr/rec-html40>
成绩单
编号
姓名
语文
数学
英语
1
jone
90
85
100
2
tom
99
85
80
thanks ~
来源:http://mp.weixin.qq.com/s?__biz=mjm5ndm4mdiwnw==&mid=2448834670&idx=1&sn=1cccfd60a7227972958d75f3d775c669#rd
更多【干货分享】,请关注我的个人订阅号。