Home > Backend Development > PHP Tutorial > Tutorial on quickly exporting Table data with PHP

Tutorial on quickly exporting Table data with PHP

jacklove
Release: 2023-03-27 15:10:02
Original
1823 people have browsed it

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 = "
Copy after login

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:

How to solve the problem that the data queried by php is garbled and the Chinese code becomes Unicode when converting to json?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template