CVS file export

    /**
     * @param $filename 文件名
     */
    public function exportCxv($filename) {
        $filename = @iconv('UTF-8', 'GBK', $filename . '.csv');
        header("Content-type:application/vnd.ms-excel");
        header("Content-Disposition:attachment;filename=" . $filename);
        header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
        header('Expires:0');
        header('Pragma:public');
        $title= "Title bar, the title bar" ;
         echo @ iconv ( 'UTF-. 8', '// GBK the IGNORE', $ title ) "\ R & lt \ n-." ; 
    } 

    / * * 
     * [CSV Export Data] 
     * @param [type] $ data [data] 
     * @return [type] [Description] 
     * / 
    public  function CSV ( $ data ) {
         IF (! empty ( $ data )) {
             the foreach ( $ data  AS  $ Key => $ value ) {
                 param $ = $ value [ 'param' ];
                $date = date("Y-m-d H:i:s", $value['$date'] ? $value['$date'] : null);
                echo '"'.@mb_convert_encoding($param, 'GBK', 'UTF-8').'",';
                echo '"'.@mb_convert_encoding($date, 'GBK', 'UTF-8').'",';
                echo " \r\n";
            }
        }
    }

 

Guess you like

Origin www.cnblogs.com/fatRabbit-/p/10973252.html