header中怎么導(dǎo)出Excel應(yīng)用,相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
江西網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項目制作,到程序開發(fā),運營維護(hù)。創(chuàng)新互聯(lián)公司自2013年起到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)公司。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= '分類,創(chuàng)意ID,創(chuàng)意類型,創(chuàng)意標(biāo)簽,創(chuàng)意標(biāo)題,創(chuàng)意描述,評論數(shù), 收藏數(shù),投票數(shù),提交人,作者'."\n"; }elseif($_POST['two_status']==1){ $csv= '分類,創(chuàng)意ID,創(chuàng)意類型,創(chuàng)意標(biāo)簽,創(chuàng)意標(biāo)題,創(chuàng)意描述,評論數(shù), 收藏數(shù),投票數(shù),提交人,作者,合作者,核心創(chuàng)新點說明,市場計劃,已有類似商業(yè)化案例,相關(guān)專利狀況,實現(xiàn)方式討論,發(fā)表時間'."\n"; }else{ $csv= '分類,創(chuàng)意ID,創(chuàng)意類型,創(chuàng)意標(biāo)簽,創(chuàng)意標(biāo)題,創(chuàng)意描述,評論數(shù), 收藏數(shù),投票數(shù),提交人,作者,合作者,核心創(chuàng)新點說明,市場計劃,已有類似商業(yè)化案例,相關(guān)專利狀況,實現(xiàn)方式討論,發(fā)表時間'."\n"; } foreach($lists as $list =>$v) { if($v['creative_type'] == 1){ $type = '問題'; }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)意分類,創(chuàng)意標(biāo)題,創(chuàng)意簡述,得票數(shù),評論數(shù), 收藏數(shù),上傳時間'."\n"; foreach($lists as $list =>$v) { if($v['creative_type'] == 1){ $type = '問題'; }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(); } } ?>
看完上述內(nèi)容,你們掌握header中怎么導(dǎo)出Excel應(yīng)用的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!