public function index(){ if($_POST){ //@param $data array 需要導(dǎo)出的數(shù)據(jù) //@param $field string 導(dǎo)出csv文件的列名 //@param $file " /> 美女厕所撒尿ass,97caopeng,国产亚洲精品久久77777

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

header導(dǎo)出Excel應(yīng)用示例

復(fù)制代碼 代碼如下:
<?php
class reportFormAction extends CommonAction{

public function index(){
if($_POST){
//@param $data array 需要導(dǎo)出的數(shù)據(jù)
//@param $field string 導(dǎo)出csv文件的列名
//@param $filename string 需要導(dǎo)出csv文件的名字
$where = '1';
$order = 'creative_id desc';
if($_POST['crea_wh'] == 1) $order .= "";
if($_POST['crea_wh'] == 2) $order .= "creative_time desc";
$star = strtotime($_POST['control_star']);
$end = strtotime($_POST['control_end']);
if($star && $end) $where .= " and (create_time between $star and $end)";
if($_POST['creative_type'] == 1) $where .= " and creative_type =1";
if($_POST['creative_type'] == 2) $where .= " and creative_type =2";
if($_POST['creative_type'] == 3) $where .= " and creative_type =3";
if($_POST['sort_name'] == 1) $where .= " and sort_name = '技術(shù)類(lèi)'";
if($_POST['sort_name'] == 2) $where .= " and sort_name = '包裝類(lèi)'";
if($_POST['sort_name'] == 3) $where .= " and sort_name = '產(chǎn)品類(lèi)'";
if($_POST['sort_name'] == 4) $where .= " and sort_name = '營(yíng)銷(xiāo)類(lèi)'";
if($_POST['sort_name'] == 5) $where .= " and sort_name = '其他類(lèi)'";
if($_POST['two_status']==0) {$where .= " and two_status=0"; $fenlei1="一句話創(chuàng)意";}
if($_POST['two_status']==1) {$where .= " and two_status=1"; $fenlei2="標(biāo)準(zhǔn)創(chuàng)意";}
$csv = '';
$lists = M('creative')->where($where)->order($order)->select();
if(is_array($lists) && count($lists)>0) {


if(empty($filename)) {
$filename = date('Y-m-d',time()).'.csv';
}
header('Content-type:application/vnd.ms-excel');
header('Content-Disposition:attachment;filename='.$filename);
header('Pragma:no-cache');
header('Expires:0');
if($_POST['two_status']==0){
$csv= '分類(lèi),創(chuàng)意ID,創(chuàng)意類(lèi)型,創(chuàng)意標(biāo)簽,創(chuàng)意標(biāo)題,創(chuàng)意描述,評(píng)論數(shù), 收藏?cái)?shù),投票數(shù),提交人,作者'."/n";
}elseif($_POST['two_status']==1){
$csv= '分類(lèi),創(chuàng)意ID,創(chuàng)意類(lèi)型,創(chuàng)意標(biāo)簽,創(chuàng)意標(biāo)題,創(chuàng)意描述,評(píng)論數(shù), 收藏?cái)?shù),投票數(shù),提交人,作者,合作者,核心創(chuàng)新點(diǎn)說(shuō)明,市場(chǎng)計(jì)劃,已有類(lèi)似商業(yè)化案例,相關(guān)專(zhuān)利狀況,實(shí)現(xiàn)方式討論,發(fā)表時(shí)間'."/n";
}else{
$csv= '分類(lèi),創(chuàng)意ID,創(chuàng)意類(lèi)型,創(chuàng)意標(biāo)簽,創(chuàng)意標(biāo)題,創(chuàng)意描述,評(píng)論數(shù), 收藏?cái)?shù),投票數(shù),提交人,作者,合作者,核心創(chuàng)新點(diǎn)說(shuō)明,市場(chǎng)計(jì)劃,已有類(lèi)似商業(yè)化案例,相關(guān)專(zhuān)利狀況,實(shí)現(xiàn)方式討論,發(fā)表時(shí)間'."/n";
}
foreach($lists as $list =>$v) {
if($v['creative_type'] == 1){
$type = '問(wèn)題';
}elseif($v['creative_type'] == 2){
$type = '解決方式';
}elseif($v['creative_type'] == 3){
$type = '新創(chuàng)意';
}
if($v['two_status']==0) $fenlei="一句話創(chuàng)意";
if($v['two_status']==1) $fenlei="標(biāo)準(zhǔn)創(chuàng)意";
if($_POST['two_status']==0){ //一句話
$csv .= $fenlei1.','.$v['creative_id'].",".$v['sort_name'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['comment_num'].','.$v['collect_num'].','.$v['vote_num'].','.$v['submitter'].','.$v['author']."/n";
}elseif($_POST['two_status']==1){ //標(biāo)準(zhǔn)
$csv .= $fenlei2.','.$v['creative_id'].",".$v['sort_name'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['comment_num'].','.$v['collect_num'].','.$v['vote_num'].','.$v['submitter'].','.$v['author'].','.$v['collaborator'].','.$v['innovation_description'].','.$v['marketing_plan'].','.$v['business_case'].','.$v['patent_situation'].','.$v['discuss_ways'].','.strtotime($v['create_time'])."/n";
}else{ //全部
$csv .= $fenlei.','.$v['creative_id'].",".$v['sort_name'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['comment_num'].','.$v['collect_num'].','.$v['vote_num'].','.$v['submitter'].','.$v['author'].','.$v['collaborator'].','.$v['innovation_description'].','.$v['marketing_plan'].','.$v['business_case'].','.$v['patent_situation'].','.$v['discuss_ways'].','.strtotime($v['create_time'])."/n";
}
}
echo mb_convert_encoding($csv,"CP936","UTF-8");

}else{
$this->assign("msg",$msg);
}
exit;
}




$this->display();
}


public function votecount(){
if($_POST){
//@param $data array 需要導(dǎo)出的數(shù)據(jù)
//@param $field string 導(dǎo)出csv文件的列名
//@param $filename string 需要導(dǎo)出csv文件的名字
$where = '1';
if($_POST['crea_order'] == 1) $order = " c.vote_num desc";
$star = strtotime($_POST['control_star']);
$end = strtotime($_POST['control_end']);
if($star && $end) $where .= " and (c.vote_start_time between $star and $end) and (c.vote_end_time between $star and $end)";
$sql ="select c.sort_name,c.creative_id,c.creative_type,c.creative_name,c.creative_description,c.vote_num,c.comment_num,c.collect_num,c.create_time, u.username from cofco_creative as c left join cofco_userinfo as u on c.uid = u.uid where $where order by $order ";
$lists = M()->query($sql);
$csv = '';
if(is_array($lists) && count($lists)>0) {


if(empty($filename)) {
$filename = date('Y-m-d',time()).'.csv';
}
header('Content-type:application/vnd.ms-excel');
header('Content-Disposition:attachment;filename='.$filename);
header('Pragma:no-cache');
header('Expires:0');


$csv = '創(chuàng)意標(biāo)簽,提交者,創(chuàng)意分類(lèi),創(chuàng)意標(biāo)題,創(chuàng)意簡(jiǎn)述,得票數(shù),評(píng)論數(shù), 收藏?cái)?shù),上傳時(shí)間'."/n";
foreach($lists as $list =>$v) {
if($v['creative_type'] == 1){
$type = '問(wèn)題';
}elseif($v['creative_type'] == 2){
$type = '解決方式';
}elseif($v['creative_type'] == 3){
$type = '新創(chuàng)意';
}
$time = date("Y-m-d H:i:s",$v['create_time']);
$csv .= $v['sort_name'].','.$v['username'].','.$type.','.$v['creative_name'].','.$v['creative_description'].','.$v['vote_num'].','.$v['comment_num'].','.$v['collect_num'].','.$time."/n";
}
echo mb_convert_encoding($csv,"CP936","UTF-8");

}else{
$this->assign("msg",$msg);
}
exit;
}

$this->display();
}
}
?>

php技術(shù)header導(dǎo)出Excel應(yīng)用示例,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 青青青青青青草 | 大陆老太交xxxxxhd在线 | 国产免费69成人精品视频 | 韩国精品无码少妇在线观看网站 | 99久久爱re热6在线播放 | 亚洲欧美日韩精品自拍 | 国产精品亚洲一区二区三区久久 | 欧美双拳极限扩张 | 亚洲精品国产品国语在线试看 | 暖暖 免费 高清 日本视频5 | 国产AV白丝爆浆在线播放 | 久久国产免费 | 亚洲七七久久桃花综合 | 波多野结衣的AV一区二区三区 | 妻子的妹妹在线 | 欧美丰满白嫩bbxx | 欧美午夜不卡在线观看 | 日本在线高清不卡免费播放 | chinesedaddy80老年人 | 精品三级久久久久电影网1 精品日韩视频 | 国产欧美第一页 | 国产精品免费大片 | 国产免费久久精品国产传媒 | 99精品国产福利在线观看 | 色裕插插插影视 | 亚州日韩精品AV片无码中文 | 国产成人啪精视频精东传媒网站 | 麻婆豆腐传媒视频免费 | 国精产品一区二区三区有限公司 | 亚洲 中文 自拍 无码 | 中文字幕亚洲第一 | china18一19 第一次 | 古风H啪肉NP文 | 伊人久久大线蕉香港三级 | 超碰视频在线观看 | 厨房玩朋友娇妻中文字幕 | 2012中文字幕手机在线 | 亚洲伊人精品综合在合线 | 双性大乳浪受噗呲噗呲h总 双性被疯狂灌满精NP | 2017最新伦理伦理片67 | 亚洲高清国产拍精品影院 |