//搜索
$start_time = strtotime($start_date);
$end_time = strtotime($end_date);
$sql = "select a.*,b.order_amount,b.money_paid from ".$ecs->table('invoice')." as a ".
" left join ".$ecs->table('order_info')." as b on a.order_id=b.order_sn".
" where a.add_time >=".$start_time." and a.add_time <=".$end_time." ";
$temp_list = $db->getAll($sql);
if($temp_list){//有数据
$Html='
'.chr(13).chr(10);$Html.='
时间: | '.$start_date.'~'.$end_date.' | ||||||||
编号 | 发票类型 | 发票抬头 | 发票内容 | 订单号 | 金额 | 添加日期 | 收件人 | 联系方式 | 地址 |
//取得符合条件的数组
for($i=0;$i
$temp_i = $i+1;
if($temp_list[$i][order_amount]==0){
$temp_money = $temp_list[$i][money_paid];
}else{
$temp_money = $temp_list[$i][order_amount];
}
$temp_time = date('Y-m-d', $temp_list[$i]['add_time']);
$Html.='
'.$temp_i.''.$temp_list[$i][type_name].''.$temp_list[$i][top].''.$temp_list[$i][content].''.$temp_list[$i][order_id].''.$temp_money.''.$temp_time.''.$temp_list[$i][user_name].''.$temp_list[$i][mobile].' '.$temp_list[$i][tel].' '.$temp_list[$i][address].'';}
$Html.='
';$Html.='';
$mime_type = 'application/vnd.ms-excel';
header('Content-Type: ' . $mime_type);
header('Content-Disposition: attachment; filename="invoice.xls"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo $Html;
有时excel会自动把数字转换格式,于是有些手机号码,身份证之类的就乱了,因此可以在导出时,先定义好
'.$temp_list[$i][order_id].'