Home > Article > Backend Development > Tutorial on quickly exporting Table data with PHP
This article explains the tutorial on quickly exporting Table data in PHP.
PHP Tutorial to quickly export Table data
//Get a certain data first
$date = input(); $id = @$date['data']; $dataResult=Db::table('demo') ->where('id','in',$id) ->select(); // $dataResult = input('data'); // $dataResult = json_decode($dataResult,true); // dump($dataResult);die; $headTitle = "XX数据"; $title = date("Y-m-d")."-"."XX数据导出数据"; // $headtitle = "{$headTitle}"; $headtitle = "{$headTitle}"; $titlename=" 编号 XX标题 姓名 年龄 性别 XX号 XX室 XX区 XX志 XX时间 XX操作 XX备注 XX修改 XX时间 XX类型 XX标识 "; $filename = $title.".xls"; // dump($title); $this->excelData($dataResult,$titlename,$headtitle,$filename); public function excelData($datas,$titlename,$title,$filename) { $str = "
This method can quickly Exporting data does not require loading the third-party phpExcel class library. The offline test environment php5.5 can be used. If the online environment is php7.0, it is recommended to use the phpexcel class library 1.81. There are some problems with php7.0 and I do not recommend this writing method.
This article explains the tutorial on quickly exporting Table data in PHP. For more related content, please pay attention to the PHP Chinese website.
Related recommendations:
Explanation of PHP array traversal examples
Explanation of PHP array classification and array creation examples
The above is the detailed content of Tutorial on quickly exporting Table data with PHP. For more information, please follow other related articles on the PHP Chinese website!