当前位置: 旋风说(旋风PHPer分享网)> 技术文章> 正文
public function outexlserver($data=array(),$title=array(),$filename='import_file_name'){ ob_end_clean(); ob_start(); header("Content-type:text/html;charset=utf-8"); header("Content-type:application/octet-stream"); header("Accept-Ranges:bytes"); header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:attachment;filename=".$filename.".xls"); header("Pragma: no-cache"); header("Expires: 0"); //导出xls 五个列分别是 a b c d e $ary = array('a','b','c','d','e'); foreach($ary as $k=>$v){ $ary[$k]=iconv("UTF-8", "GBK",$v);//转码 } $title= implode("\t", $ary); echo "$title\n"; if(!is_array($data)){ $data = $data->all(); } if(!empty($data)){ foreach($data as $key=>$v){ $ary2 = ''; if($v['source']==1){ $source = '张三'; } if($v['source']==2){ $source = '李四'; } if($v['source']==3){ $source = '王五'; } if($v['source']==4){ $source = '赵六'; } $source=iconv("UTF-8", "GBK", $source); $source_account=iconv("UTF-8", "GBK", $v['source_account']); $prices=iconv("UTF-8", "GBK", $v['prices']); $ary2 = array($v['name1'],$v['name2'],'$source,$source_account,$prices); $datas[$key] = implode("\t", $ary2); } echo implode("\n",$datas); } }
当您发现内容错误或代码bug,以及下载链接无法使用等,请点击屏幕右下角的上报错误来进行提交,我们会尽快修正。
本程序所有源码和工具完全免费,当本网站内容如果侵犯了您的权益,请联系我们,我们会尽快处理,感谢您的合作。
相关文章
评论:
文明上网理性发言,请遵守 新闻评论服务协议