/* * 数据导出下载方法 */ function download() { $Provider = $this->trunk_model->getEditProvider (); $filename=str_replace('-','',date('Y-m-j')); header ( "Content-typefile_type;charset=GB2312" ); header ( "Content-type:application nd.ms-excel" ); header ( "Content-Disposition:filename=$filename.xls" ); foreach ( $Provider->result_array () as $row ): { //主要实现编码错误问题 print iconv("UTF-8","GB2312//IGNORE",$row ['id'])."/t" ; print iconv("UTF-8","GB2312//IGNORE",$row ['provider_name'])."/t" ; print iconv("UTF-8","GB2312//IGNORE",$row ['creationdate'])."/t" ; print iconv("UTF-8","GB2312//IGNORE",$row ['description'])."/t/n" ; } endforeach; //CI自带的方法,此处以用解决了Linux下市打开文件不是下载文件的问题。 force_download('$filename.xls'); }