$list = db('orderno_dk')->alias('ord')
->join('repay_dk r','ord.account_number=r.account_number')
->field($fields)
->where($where)
->select();

$filename = date("Y-m-d")."系统充值回盘数据导出";
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");

$title = array("合同编号","借款人姓名","身份证号码","还款类型","还款方式","入账金额","整月还款金额","开始还款时间","分期数","还款日","是否结清","还款银行","还款账期 ","账龄","渠道");

foreach ($title as $k => $v) {
$title[$k] = mb_convert_encoding($v, "GBK", "UTF-8");
}
$title = implode("\t", $title);
echo "$title\n";

if ($list)
{
sort($list);
$excel = '';
foreach ($list as $k => $val) {
$excel .= implode("\t",$val)."\n";
}
}

$excel = mb_convert_encoding($excel, "GBK", "UTF-8");
echo $excel;
12-29 20:31