选择当天一周一月导出excel表格
<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表格的更多相关文章
- NPOI_winfrom导出Excel表格(一)(合并单元格、规定范围加外边框、存储路径弹框选择)
1.导出 private void btn_print_Click(object sender, EventArgs e) { DataTable dtNew = new DataTable(); d ...
- java 实现用户自由选择字段实现导出EXCEL表格
package com.thinkgem.jeesite.common.utils.excel; import java.io.File; import java.io.OutputStream; i ...
- .NET环境下导出Excel表格的两种方式和导入两种类型的Excel表格
一.导出Excel表格的两种方式,其中两种方式指的是导出XML数据类型的Excel(即保存的时候可以只需要修改扩展名为.xls)和真正的Excel这两种. using System; using Sy ...
- NPOI_winfrom导出Excel表格(二)(直接打开Excel软件,将数据填充在当前的sheet中)
//// 存储路径弹框选择 SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.DefaultExt = "xls&qu ...
- PHP导入导出excel表格图片(转)
写excel的时候,我用过pear的库,也用过pack压包的头,同样那些利用smarty等作的简单替换xml的也用过,csv的就更不用谈了.呵呵.(COM方式不讲了,这种可读的太多了,我也写过利用wp ...
- java中使用jxl导出Excel表格详细通用步骤
该方法一般接收两个参数,response和要导出的表格内容的list. 一般我们将数据库的数据查询出来在页面进行展示,根据用户需求,可能需要对页面数据进行导出. 此时只要将展示之前查询所得的数据放入s ...
- java导出excel表格
java导出excel表格: 1.导入jar包 <dependency> <groupId>org.apache.poi</groupId> <artifac ...
- 使用NPOI将数据库里信息导出Excel表格并提示用户下载
使用NPOI进行导出Excel表格大家基本都会,我在网上却很少找到导出Excel表格并提示下载的 简单的代码如下 //mvc项目可以传多个id以逗号相隔的字符串 public ActionResult ...
- VB.NET版机房收费系统---导出Excel表格
datagridview,翻译成中文的意思是数据表格显示,使用DataGridView控件,能够显示和编辑来自不同类型的数据源的表格,将数据绑定到DataGridView控件很easy和直观,大多数情 ...
随机推荐
- 【转】SAP HANA学习资料大全[非常完善的学习资料汇总]
Check out this SDN blog if you plan to write HANA Certification exam http://scn.sap.com/community/ha ...
- Codeforces339D(SummerTrainingDay06-A 线段树)
D. Xenia and Bit Operations time limit per test:2 seconds memory limit per test:256 megabytes input: ...
- python学习之老男孩python全栈第九期_day007知识点总结
基础数据类型汇总 1. str 2. int 3. list 4. bool 5. dict (1) fromkeys Python 字典 fromkeys() 方法用于创建一个新的字典,并以可迭代对 ...
- js飘窗
广告页上总会出现飘窗效果: adver_pos_id = getOtherParameter("id"); adver_Sid = getOtherParameter(" ...
- 排序算法(2)--Insert Sorting--插入排序[2]--binary insertion sort--折半(二分)插入排序
作者QQ:1095737364 QQ群:123300273 欢迎加入! 1.基本思想 二分法插入排序的思想和直接插入一样,只是找合适的插入位置的方式不同,这里是按二分法找到合适的位置,可 ...
- Vue知识点(面试常见点)
v-bind和v-model的区别 1.v-bind用来绑定数据和属性以及表达式,缩写为':' 2.v-model使用在表单中,实现双向数据绑定的,在表单元素外使用不起作用 什么是 mvvm? MVV ...
- AngularJS学习之 angular-file-upload控件使用方法
1.官方链接 https://github.com/nervgh/angular-file-upload 2.安装到项目中 bower install angular-file-upload(安装完成 ...
- springboot 学习之路 18(webflux详细介绍(2))
webflux的详细介绍 引言:上一节已经简单介绍webflux的一些基本概念,本章继续学习webflux的原理和实战方面的东西: Spring WebFlux架构: note:注意理解上面这张图.下 ...
- 团队项目个人进展——Day07
一.昨天工作总结 冲刺第七天,学习了微信小程序中WebSocket 连接,如果当前已存在一个 WebSocket 连接,会自动关闭该连接,并重新创建一个 WebSocket 连接. 二.遇到的问题 对 ...
- 记一次服务器迁移后的nginx启动问题
背景 服务器A准备下线,故直接将上面的所有应用/资料打包迁移到服务器B.包括搭建的nginx,迁移到B服务器后,楼主偷懒,就想着直接./nginx启动,过程遇到如下问题. ./nginx ./ngin ...