标签:tom ESS business flush nes type res tac array
function ExportStoreInfoAction() { set_time_limit(0); $table = "xd_store"; $res = [[...]...]; if($res) { $titles = array(‘序号‘, ‘门店编号‘, ‘门店名称‘,‘门店电话‘, ‘分司代码‘, ‘分司名称‘, ‘打印机编号‘, ‘状态‘); $tableName = ‘xxx‘; ob_get_clean(); ob_start(); /*输入到CSV文件 解决乱码问题*/ echo "\xEF\xBB\xBF"; echo implode("\t ,", $titles)."\n"; foreach ($res as $key => $row) {
# $customre_memo = preg_replace("/(\n)|(\t)|(,)|(,)/" ,‘!‘ ,$row[‘customre_memo‘]);
# 注意这里是以逗号分隔的 所以如果你的内容中包含有逗号,就会造成导出后 execl 发现自动多换行了,这时你就需要 来这里替换掉逗号*(你的分隔符是什么 就替换什么,替换内容自定义,可以为空 可以为其他符号)
$rows = array(); $k = $key + 1; $rows[‘id‘] = $k; $rows[‘store_id‘] = $row["store_id"]; $rows[‘storename‘] = $row["storename"]; $rows[‘tel‘] = $row["tel"]; $rows[‘company_id‘] = $row["company_id"]; $rows[‘name‘] = $row["name"]; $rows[‘address‘] = $row["front_province"] . ‘ ‘ . $row["front_city"] . ‘ ‘ . $row["front_area"] . ‘ ‘ . $row["front_address"]; $rows[‘status‘] = Data::$_store_business_status[$row[‘business_status‘]] ; echo implode("\t ,", $rows)."\n"; } header(‘Content-Disposition: attachment; filename=‘ . $tableName . ".csv"); header(‘Accept-Ranges:bytes‘); header(‘Content-Length:‘ . ob_get_length()); header(‘Content-Type:text/csv‘); // csv 格式 ob_end_flush(); exit; } } }
标签:tom ESS business flush nes type res tac array
原文地址:https://www.cnblogs.com/G921123/p/11813958.html