Chinaunix首页 | 论坛 | 博客
  • 博客访问: 149230
  • 博文数量: 89
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 70
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-29 23:10
文章分类

全部博文(89)

文章存档

2016年(89)

我的朋友

分类: Web开发

2016-03-22 20:22:03

//搜索
    $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='
                            
                                    时间:
                                    '.$start_date.'~'.$end_date.'
                            
                            
                                     编号
                                     发票类型
                                     发票抬头
                                     发票内容
                                     订单号
                                     金额
                                     添加日期
                                     收件人
                                     联系方式
                                     地址
                           ';
            //取得符合条件的数组
            for($i=0;$i
                                     '.$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].'

转载自:

阅读(798) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~