PHP导出CSV php 导出 csv php export csv php create csv fil
程序员文章站
2022-04-21 15:11:48
...
//导出csv
function export_csv($filename,$data) {
header("Content-type:text/csv;charset=utf-8");
header("Content-Disposition:attachment;filename=".$filename);
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0');
header('Pragma:public');
echo $data;
}
$data = $component->getFeedBackList($city_en,$date,0,0);
$str = "楼盘名,是否已回访\n";
$str = iconv('utf-8','gb2312',$str); //中文转码
if ($data){
foreach ($data as $d){
$name = iconv('utf-8','gb2312',$d['house_name']); //中文转码
$vis = $d['is_visited']=='y'?"已回访":"未回访";
$vis = iconv('utf-8','gb2312',$vis);
$str.= $name.",".$vis."\n";
}
}
$filename = $date['start']."-".$date['end'].$city_cn.'来电回访情况.csv'; //设置文件名
export_csv($filename,$str); //导出
function export_csv($filename,$data) {
header("Content-type:text/csv;charset=utf-8");
header("Content-Disposition:attachment;filename=".$filename);
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0');
header('Pragma:public');
echo $data;
}
$data = $component->getFeedBackList($city_en,$date,0,0);
$str = "楼盘名,是否已回访\n";
$str = iconv('utf-8','gb2312',$str); //中文转码
if ($data){
foreach ($data as $d){
$name = iconv('utf-8','gb2312',$d['house_name']); //中文转码
$vis = $d['is_visited']=='y'?"已回访":"未回访";
$vis = iconv('utf-8','gb2312',$vis);
$str.= $name.",".$vis."\n";
}
}
$filename = $date['start']."-".$date['end'].$city_cn.'来电回访情况.csv'; //设置文件名
export_csv($filename,$str); //导出
以上就介绍了PHP导出CSV,包括了php,csv方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
上一篇: phpMyAdmin程序安装讲解
下一篇: Nginx运行和控制命令