PHP将操作数据库得到的数据生成Excel导出
来源:互联网 发布:极速开票软件 编辑:程序博客网 时间:2024/05/22 12:09
public function export()
{
Header( "Content-type: application/octet-stream ");
Header( "Accept-Ranges: bytes ");
Header( "Content-type:application/vnd.ms-excel ");
Header( "Content-Disposition:attachment;filename=ExportDate.xls ");
$where="1=1";
$date=$_POST["date_exp"];
if($date=="今天")
{
$time1 = strtotime(date("Y-m-d",time()));
$time2 = $time1 + 3600*24;
$where = $where." and `inputtime` between '$time1' and '$time2' ";
}
else if($date=="昨天")
{
$time1 = strtotime(date("Y-m-d",time()));
$time2 = $time1 - 3600*24;
$where =$where. " and `inputtime` between '$time2' and '$time1' ";
}
else if($date=="上周")
{
$now = time();
$date = $now - 7*24*60*60;
$where=$where." and `inputtime` >= '$date' ";
}
else if($date=="最近30天")
{
$now = time();
$date = $now - 30*24*60*60;
$where=$where." and `inputtime` >= '$date' ";
}
$this->db->set_model(12); //12对应于content模块对应的modelid
$dates=$this->db->select($where,'*','','inputtime desc');
echo "ID \t 栏目\t 姓名 \t详细地址 \t QQ \t Email \t 电话 \t 手机 \t 发布日期 \n";
for ($i=0;$i<count($dates);$i++)
{
echo $dates[$i][id]."\t";
echo $dates[$i][catid]."\t".$dates[$i][name]."\t".$dates[$i][address]."\t".$dates[$i][qq]."\t".$dates[$i][email]."\t".$dates[$i][telephone]."\t".$dates[$i][mobilephone]."\t".date("Y-m-d H:i",$dates[$i][inputtime])."\n";
}
}
{
Header( "Content-type: application/octet-stream ");
Header( "Accept-Ranges: bytes ");
Header( "Content-type:application/vnd.ms-excel ");
Header( "Content-Disposition:attachment;filename=ExportDate.xls ");
$where="1=1";
$date=$_POST["date_exp"];
if($date=="今天")
{
$time1 = strtotime(date("Y-m-d",time()));
$time2 = $time1 + 3600*24;
$where = $where." and `inputtime` between '$time1' and '$time2' ";
}
else if($date=="昨天")
{
$time1 = strtotime(date("Y-m-d",time()));
$time2 = $time1 - 3600*24;
$where =$where. " and `inputtime` between '$time2' and '$time1' ";
}
else if($date=="上周")
{
$now = time();
$date = $now - 7*24*60*60;
$where=$where." and `inputtime` >= '$date' ";
}
else if($date=="最近30天")
{
$now = time();
$date = $now - 30*24*60*60;
$where=$where." and `inputtime` >= '$date' ";
}
$this->db->set_model(12); //12对应于content模块对应的modelid
$dates=$this->db->select($where,'*','','inputtime desc');
echo "ID \t 栏目\t 姓名 \t详细地址 \t QQ \t Email \t 电话 \t 手机 \t 发布日期 \n";
for ($i=0;$i<count($dates);$i++)
{
echo $dates[$i][id]."\t";
echo $dates[$i][catid]."\t".$dates[$i][name]."\t".$dates[$i][address]."\t".$dates[$i][qq]."\t".$dates[$i][email]."\t".$dates[$i][telephone]."\t".$dates[$i][mobilephone]."\t".date("Y-m-d H:i",$dates[$i][inputtime])."\n";
}
}
0 0
- PHP将操作数据库得到的数据生成Excel导出
- php将数据库数据导出成Excel
- 将从数据库中得到的数据,导出到excel表中(得到的数据使用的List泛型)
- PHP将Excel导入数据库及数据库数据导出至Excel的方法
- PHP将Excel导入数据库及数据库数据导出至Excel的方法 亲测
- 如何将C#中将TextBox的数据以及从数据库中查询得到的数据导出到Excel中
- 用php将数据库中数据导出成excel表格
- 如何将数据库的表导出生成Excel?
- php将数据库导出成excel的方法
- PHP 将大量数据导出到 Excel 的方法
- php 将数据 以excel 表格的形式导出
- PHP 将大量数据导出到 Excel 的方法
- PHP 将大量数据导出到 Excel 的问题
- 将数据导出到excel文件的操作类
- 将数据库的数据导出到EXCEL中
- asp将数据库的数据转换成excel导出
- 将数据库的数据导出到Excel表中
- 将数据库里的数据导出到EXCEL中的方法
- 背包型动态规划1014装箱问题
- 有效地址传送指令 LEA
- WifiService和wpa_supplicant的启动流程跟踪
- 设计模式-单例模式
- IT 圈里经常被读错的词
- PHP将操作数据库得到的数据生成Excel导出
- reunet 在家开着电脑挂个东西就能每天有收入
- eclipse经常卡死的问题
- C++将HTML特殊字符转换成正常字符
- 客户端存储技术-PersistJS
- PHP将服务器上的文件下载(例如下载Excel模板)
- C++构造函数 explicit
- 程序员面试题目总结(持续更新)
- OC学习(一)类的定义和对象的创建