header匯出Excel應用示例

2022-10-06 12:36:12 字數 1756 閱讀 3711

複製** **如下:

php

class reportformaction extends commonaction

if($_post['two_status']==1)

$csv = '';

$lists = m('creative')->where($where)->order($order)->select();

if(is_array($lists) && count($lists)>0)

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)elseif($_post['two_status']==1)else

foreach($lists as $listwww.cppcns.com =>$v) elseif($v['creative_type'] == 2)elseif($v['creative_type'] == 3)

if($v['two_status']==0) $fenlei="一句話創意";

if($v['two_status']==1) $fenlei="標準創意";

if($_post['two_status']==0)elseif($_post['two_status']==1)else

} echo mb_convert_encoding($csv,"cp936","utf-8");

}else

exit;

} $this->display();

} public function votecount()

header('content-type:application/vnd.ms-excel');

header('content-disposition:attachm程式設計客棧ent;filename='.$filename);

header('pragma:no-cache');

header(nhhott'expires:0');

$csv = '創意標籤,提交者,創意分類,創意標題,創意簡述,得票數,評論數, 數,上傳時間'."\n";

foreach($lists as $list =>$v) elseif($v['creative_type'] == 2)elseif($v['creative_type'] == 3)

$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

exit;

} $this->display();

} }

?>

本文標題: header匯出excel應用示例

本文位址:

C 匯出Excel 匯出資料到Excel模板檔案裡

using excel microsoft.office.interop.excel using system.reflection missing 開啟模板檔案,得到workbook物件 workbook excel.workbooks.open templatepath,missing,miss...

C 讀取Excel,匯出Excel

c 讀取excel 方法一 oledb方式 1 定義連線字串 string strconn provider microsoft.jet.oledb.4.0 data source exce檔案路徑及名字 extended properties excel 8.0 hdr false imex 1 ...

C 讀取Excel,匯出Excel

c 讀取excel 方法一 oledb方式 1 定義連線字串 string strconn provider microsoft.jet.oledb.4.0 data source exce檔案路徑及名字 extended properties excel 8.0 hdr false imex 1 ...