public  function exportToExcel($filename, $tileArray=[], $dataArray=[]){

        ini_set('memory_limit','512M');

        ini_set('max_execution_time',0);

        ob_end_clean();

        ob_start();

        header("Content-Type: text/csv");

        header("Content-Disposition:filename=".$filename);

        $fp=fopen('php://output','w');

        fwrite($fp, chr(0xEF).chr(0xBB).chr(0xBF));//转码 防止乱码(比如微信昵称(乱七八糟的))

        fputcsv($fp,$tileArray);

        $index = 0;

        foreach ($dataArray as $item) {

            if($index==1000){

                $index=0;

                ob_flush();

                flush();

            }

            $index++;

            fputcsv($fp,$item);

        }



        ob_flush();

        flush();

        ob_end_clean();

    }

 

相关文章:

  • 2021-06-27
  • 2022-12-23
  • 2021-09-11
  • 2022-02-02
  • 2021-09-16
  • 2022-12-23
  • 2021-10-06
猜你喜欢
  • 2022-12-23
  • 2021-05-17
  • 2022-12-23
  • 2021-06-23
  • 2022-01-14
  • 2021-12-05
相关资源
相似解决方案