<a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10" onclick="window.location.reload()">刷新</a>

<a href="javascript:;" class="fr btn btn-primary radius mt-6 mr-10 btn_excel" title="导出Excel报表">导出Excel</a>

<select id="verifystatusd" class="select">
<option value="0">导出时间</option>
<option value="1">一天</option>
<option value="2">一周</option>
<option value="3">本月</option>
</select>

  

 //导出excel
$(".btn_excel").click(function(){
var time = $('#verifystatusd').val();
console.log(time);
window.location.href = SITEURL+"member/exportfp_excel?time=" + time;
});
 /**
* 发票导出
*/ public function exportfp_excel()
{
//本天
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//本周
$weekf = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
$weeke = mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
//本月
$monthf = mktime(0, 0 , 0,date("m"),1,date("Y"));
$monthe = mktime(23,59,59,date("m"),date("t"),date("Y")); $time = intval(Arr::get($_GET, 'time')); $where = 'WHERE';
switch ($time) {
case '0':
$where .= "`applytime` BETWEEN ". $monthf ." and ". $monthe;
break;
case '1':
$where .= " `applytime` BETWEEN ". $beginToday ." and ". $endToday;
break; case '2':
$where .= " `applytime` BETWEEN ". $weekf ." and ". $weeke;
break; case '3':
$where .= " `applytime` BETWEEN ". $monthf ." and ". $monthe;
break; default:
$where .= " `applytime` BETWEEN ". $monthf ." and ". $monthe;
break;
}
//链表查询出用户信息以及发票信息。作为导出表格内容
$sql="select s.*,m.nickname,m.truename,m.mobile from sline_applyinvoice as s left join sline_member as m on s.mid = m.mid {$where} ORDER BY `applytime` DESC";
//$sql = "SELECT * FROM `sline_applyinvoice` {$where} ORDER BY `applytime` DESC"; $rows = DB::query(1, $sql)
->execute()
->as_array();
foreach ($rows as $key => &$value) {
$value['applytime'] = date('Y-m-d H:i:s', $value['applytime']);
}
// print_r($rows);die;
$table = "<table><tr>";
$table .= "<td>昵称</td>";
$table .= "<td>真实姓名</td>";
$table .= "<td>手机号</td>";
$table .= "<td>申请状态</td>";
$table .= "<td>申请金额</td>";
$table .= "<td>申请时间</td>";
$table .= "</tr>"; $verify_arr = array(
0 => '未通过',
1 => '已通过',
);
foreach ($rows as $row)
{
$table .= "<tr>";
$table .= "<td>{$row['nickname']}</td>";
$table .= "<td>{$row['truename']}</td>";
$table .= "<td>{$row['mobile']}</td>";
$table .= "<td>{$verify_arr[$row['status']]}</td>"; $table .= "<td>{$row['amount']}</td>"; $table .= "<td>{$row['applytime']}</td>"; $table .= "</tr>";
} $table .= "</table>";
$filename = date('Ymdhis');
ob_end_clean();//清除缓冲区
header('Pragma:public');
header('Expires:0');
header('Content-Type:charset=utf-8');
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Content-Type:application/force-download');
header('Content-Type:application/vnd.ms-excel');
header('Content-Type:application/octet-stream');
header('Content-Type:application/download');
header('Content-Disposition:attachment;filename=' . $filename . ".xls");
header('Content-Transfer-Encoding:binary'); $code = mb_detect_encoding($table, array('ASCII', 'GB2312', 'UTF-8'));
if ($code != 'UTF-8')
{
$table = mb_convert_encoding($table, 'UTF-8', $code);
} exit($table);
}

注意:以上是我修改后的代码:源代码是:

/**
* @function 导出会员
*/
public function action_export_excel()
{
$verifystatus = intval(Arr::get($_GET, 'verifystatus'));
$sex = Arr::get($_GET, 'sex');
$virtual = intval(Arr::get($_GET, 'virtual'));
$where = 'WHERE 1 = 1';
if ($verifystatus != -1)
{
$where .= " AND `verifystatus` = {$verifystatus} ";
}
if ($sex != 0)
{
$where .= " AND `sex` = '{$sex}' ";
}
if ($virtual != 0)
{
$where .= " AND `virtual` = {$virtual} ";
}
$sql = "SELECT * FROM `sline_member` {$where} ORDER BY `jointime` DESC"; $rows = DB::query(1, $sql)
->execute()
->as_array();
    //上面是根据需求查询出需要导出的数据。下面是表格的设定
$table = "<table><tr>";
$table .= "<td>昵称</td>";
$table .= "<td>真实姓名</td>";
$table .= "<td>性别</td>";
$table .= "<td>会员等级</td>";
$table .= "<td>钱包总额</td>";
$table .= "<td>邮箱</td>";
$table .= "<td>手机号</td>";
$table .= "<td>积分</td>";
$table .= "<td>加入时间</td>";
$table .= "<td>加入IP</td>";
$table .= "<td>邮箱验证</td>";
$table .= "<td>手机验证</td>";
$table .= "<td>省份</td>";
$table .= "<td>城市</td>";
$table .= "<td>身份证号</td>";
$table .= "<td>地址</td>";
$table .= "<td>邮政编码</td>";
$table .= "<td>备注</td>";
$table .= "<td>注册类型</td>";
$table .= "<td>出生年月</td>";
$table .= "<td>星座</td>";
$table .= "<td>QQ</td>";
$table .= "<td>个性签名</td>";
$table .= "<td>实名认证</td>";
$table .= "<td>微信号</td>";
$table .= "<td>籍贯</td>";
$table .= "<td>冻结金额</td>";
$table .= "<td>用户类型</td>";
$table .= "</tr>"; $verify_arr = array(
0 => '未认证',
1 => '审核中',
2 => '已认证',
3 => '未通过',
);
foreach ($rows as $row)
{
$table .= "<tr>";
$table .= "<td>{$row['nickname']}</td>";
$table .= "<td>{$row['truename']}</td>";
$table .= "<td>{$row['sex']}</td>";
$table .= "<td>" . Common::member_rank($row['mid'],array('return'=>'rankname')) . "</td>";
$table .= "<td style='vnd.ms-excel.numberformat:@'>{$row['money']}</td>";
$table .= "<td>{$row['email']}</td>";
$table .= "<td style='vnd.ms-excel.numberformat:@'>{$row['mobile']}</td>";
$table .= "<td style='vnd.ms-excel.numberformat:@'>{$row['jifen']}</td>";
$jointime = $row['jointime'] ? date('Y-m-d H:i:s', $row['jointime']) : '';
$table .= "<td>" . $jointime . "</td>";
$table .= "<td>{$row['joinip']}</td>";
$checkmail = $row['checkmail'] == 1 ? '已验证' : '未验证';
$checkphone = $row['checkphone'] == 1 ? '已验证' : '未验证';
$table .= "<td>". $checkmail ."</td>";
$table .= "<td>". $checkphone ."</td>";
$table .= "<td>{$row['province']}</td>";
$table .= "<td>{$row['city']}</td>";
$table .= "<td style='vnd.ms-excel.numberformat:@'>{$row['cardid']}</td>";
$table .= "<td>{$row['address']}</td>";
$table .= "<td style='vnd.ms-excel.numberformat:@'>{$row['postcode']}</td>";
$table .= "<td>{$row['remarks']}</td>";
$regtype = $row['regtype'] == 1 ? '邮箱' : '手机';
$table .= "<td>". $regtype ."</td>";
$table .= "<td>{$row['birth_date']}</td>";
$table .= "<td>{$row['constellation']}</td>";
$table .= "<td>{$row['qq']}</td>";
$table .= "<td>{$row['signature']}</td>";
$table .= "<td>" . $verify_arr[$row['verifystatus']] . "</td>";
$table .= "<td>{$row['wechat']}</td>";
$table .= "<td>{$row['native_place']}</td>";
$table .= "<td style='vnd.ms-excel.numberformat:@'>{$row['money_frozen']}</td>";
$virtual = $row['virtual'] == 1 ? '普通用户' : '虚拟用户';
$table .= "<td>". $virtual ."</td>";
$table .= "</tr>";
} $table .= "</table>";
$filename = date('Ymdhis');
ob_end_clean();//清除缓冲区
header('Pragma:public');
header('Expires:0');
header('Content-Type:charset=utf-8');
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Content-Type:application/force-download');
header('Content-Type:application/vnd.ms-excel');
header('Content-Type:application/octet-stream');
header('Content-Type:application/download');
header('Content-Disposition:attachment;filename=' . $filename . ".xls");
header('Content-Transfer-Encoding:binary'); $code = mb_detect_encoding($table, array('ASCII', 'GB2312', 'UTF-8'));
if ($code != 'UTF-8')
{
$table = mb_convert_encoding($table, 'UTF-8', $code);
} exit($table);
}

选择当天一周一月导出excel表格的更多相关文章

  1. NPOI_winfrom导出Excel表格(一)(合并单元格、规定范围加外边框、存储路径弹框选择)

    1.导出 private void btn_print_Click(object sender, EventArgs e) { DataTable dtNew = new DataTable(); d ...

  2. java 实现用户自由选择字段实现导出EXCEL表格

    package com.thinkgem.jeesite.common.utils.excel; import java.io.File; import java.io.OutputStream; i ...

  3. .NET环境下导出Excel表格的两种方式和导入两种类型的Excel表格

    一.导出Excel表格的两种方式,其中两种方式指的是导出XML数据类型的Excel(即保存的时候可以只需要修改扩展名为.xls)和真正的Excel这两种. using System; using Sy ...

  4. NPOI_winfrom导出Excel表格(二)(直接打开Excel软件,将数据填充在当前的sheet中)

    //// 存储路径弹框选择 SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.DefaultExt = "xls&qu ...

  5. PHP导入导出excel表格图片(转)

    写excel的时候,我用过pear的库,也用过pack压包的头,同样那些利用smarty等作的简单替换xml的也用过,csv的就更不用谈了.呵呵.(COM方式不讲了,这种可读的太多了,我也写过利用wp ...

  6. java中使用jxl导出Excel表格详细通用步骤

    该方法一般接收两个参数,response和要导出的表格内容的list. 一般我们将数据库的数据查询出来在页面进行展示,根据用户需求,可能需要对页面数据进行导出. 此时只要将展示之前查询所得的数据放入s ...

  7. java导出excel表格

    java导出excel表格: 1.导入jar包 <dependency> <groupId>org.apache.poi</groupId> <artifac ...

  8. 使用NPOI将数据库里信息导出Excel表格并提示用户下载

    使用NPOI进行导出Excel表格大家基本都会,我在网上却很少找到导出Excel表格并提示下载的 简单的代码如下 //mvc项目可以传多个id以逗号相隔的字符串 public ActionResult ...

  9. VB.NET版机房收费系统---导出Excel表格

    datagridview,翻译成中文的意思是数据表格显示,使用DataGridView控件,能够显示和编辑来自不同类型的数据源的表格,将数据绑定到DataGridView控件很easy和直观,大多数情 ...

随机推荐

  1. Net 使用UEditor笔记

    WebForm使用Ueditor获取编辑器的值有两种方法:1.通过前台js 获取 function test() { alert(UE.getEditor('控件Id').getContent()); ...

  2. MVC解决WebFrom的缺点

    来自:http://www.cnblogs.com/xiaozhi_5638/p/4019065.html ASP.NET Webforms Behind Code的好处和存在的问题 ASP.NET ...

  3. 转载 HashSet用法

    NET 3.5在System.Collections.Generic命名空间中包含一个新的集合类:HashSet<T>.这个集合类包含不重复项的无序列表.这种集合称为“集(set)”.集是 ...

  4. <mvn:default-servlet-handler/>标签作用

    servlet在找页面时,走的是dispatcherServlet路线.找不到的时候会报404 加上这个默认的servlet时候,servlet在找不到的时候会去找静态的内容.

  5. Java虚拟机 - 多态性实现机制

    [深入Java虚拟机]之五:多态性实现机制——静态分派与动态分派 方法解析 Class文件的编译过程中不包含传统编译中的连接步骤,一切方法调用在Class文件里面存储的都只是符号引用,而不是方法在实际 ...

  6. 面试中常问的List去重问题,你都答对了吗?

    面试中经常被问到的list如何去重,用来考察你对list数据结构,以及相关方法的掌握,体现你的java基础学的是否牢固. 我们大家都知道,set集合的特点就是没有重复的元素.如果集合中的数据类型是基本 ...

  7. VMware打开虚拟机没反应的解决方案(全面汇总)

    VMware打开虚拟机无反应的解决方案(全面汇总)虚拟机没反应的解决办法大概是如下几点:一.若是第一次安装后打不开虚拟机,大致是如下两种解决方案: 1.大多数时候,虚拟机打不开都是因为防火墙拦截所致 ...

  8. 【 js 算法类】这么全的数组去重,你怕不怕?

    以 var arr = [1,2,3,1]; 作为测试用例 方法一:双循环   (时间复杂度比较高,性能一般.) A.(1) function unique(arr) { var newArr = [ ...

  9. python学习之老男孩python全栈第九期_day015作业_老男孩Python全9期练习题(面试真题模拟)

    一. 选择题(32分) 1. python不支持的数据类型有:AA. charB. intC. floatD. list 2. Ex = ‘foo’y = 2print(x + y)A. fooB. ...

  10. node 搭建静态服务

    对于Node.js新手,搭建一个静态资源服务器是个不错的锻炼,从最简单的返回文件或错误开始,渐进增强,还可以逐步加深对http的理解. 基本功能 不急着写下第一行代码,而是先梳理一下就基本功能而言有哪 ...