您现在的位置是:PHP导出Excel文件
PHP导出Excel文件
<?php //输出的文件类型为excel header("Content-type:application/vnd.ms-excel"); //提示下载 header("Content-Disposition:attachement;filename=jishu8_".date("Ymd").".xls"); //报表数据 $ReportArr = array(array(1,2,3,4,5), array('A','B','C','D','E'), array('up','down','left','right','center'), array('欢','迎','光','临','技','术','吧','!') ); $ReportContent = ''; $num1 = count($ReportArr); for($i=0;$i<$num1;$i++){ $num2 = count($ReportArr[$i]); for($j=0;$j<$num2;$j++){ //ecxel都是一格一格的,用\t将每一行的数据连接起来 $ReportContent .= '"'.$ReportArr[$i][$j].'"'."\t"; } //最后连接\n 表示换行 $ReportContent .= "\n"; } //用的utf-8 最后转换一个编码为gb $ReportContent = mb_convert_encoding($ReportContent,"gb2312","utf-8"); //输出即提示下载 echo $ReportContent; ?>
站长简介
分类
最新文章
热门文章
- 微信支付退款结果通知解密
- Linux修改密码提示passwd /usr/share/cracklib/pw_dict: error reading header
- 到ICANN投诉三五互联获取域名转移密码成功
- {"errcode":45047,"errmsg":"out of response count limit hint]"}
- 微信html弹出点击右上角分享到朋友圈
- CentOS使用chkconfig提示systemctl enable xxxx.service
- PHP将B转换为KB、MB、GB
- Apache禁用TRACE Method和添加X-frame-options响应头
- mysqld_safe Number of processes running now
- 构建微信公众号被动回复image图片消息xml