Home PHP Libraries Other libraries PHP class to export excel table
PHP class to export excel table
<?php
  public function setEncode($incode,$outcode){
    $this->inEncode=$incode;
    $this->outEncode=$outcode;
  }
  public function setTitle($titlearr){
    $title="";
    foreach($titlearr as $v){
      if($this->inEncode!=$this->outEncode){
        $title.=iconv($this->inEncode,$this->outEncode,$v)."\t";
      }
      else{
        $title.=$v."\t";
      }
    }
    $title.="\n";
    return $title;
  }

Usage method

$excel=new Excel();

Set encoding:

$excel->setEncode("utf-8" ,"gb2312"); //If you don't want to transcode, just write the same parameters, for example $excel->setEncode("utf-8","utf-8");

settings Title bar

$titlearr=array("a","b","c","d");

Set content bar

$contentarr=array(

1=>array("ab","ac","ad","ae"),

2=>array( "abc","acc","adc","aec"),

3=>array("abd","acd","add","aed"),

4=>array("abe","ace","ade","aee"),

);

$excel->getExcel($titlearr,$ contentarr,"abc");


Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

php export data to excel class php export data to excel class

25 Jul 2016

php export data to excel class

Export data in html to excel table using javscript Export data in html to excel table using javscript

18 Jul 2017

<script language="JavaScript" type="text/javascript"> /* * Default conversion implementation function, if you need other functions, you need to extend it yourself * Parameters: * tableID: Table object id attribute value in HTML * For detailed usage, see TableToExcel below Object definition */ function saveAsExcel(tableID){ va

How to export table structure to excel in navicat How to export table structure to excel in navicat

24 Apr 2024

The steps to export a table structure to Excel in Navicat are as follows: After opening the database connection, find the target table in the Object Manager. Right-click on the target table and select Export Wizard. Select "Export to other database" and click "Next". Select "Excel Sheet" as the export format. Click "Options" and check "Export table structure only". Select the export destination. Click "Export" to start the export process. Navicat will export an Excel file containing a table structure.

PHP does not use open source libraries to export mysql data to Excel files PHP does not use open source libraries to export mysql data to Excel files

25 Jul 2016

PHP does not use open source libraries to export mysql data to Excel files

How to export excel table with php (code) How to export excel table with php (code)

28 Sep 2018

The content of this article is about sharing the method (code) of exporting excel tables with PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. A brief introduction to the switch statement in JavaScript (with code) has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Operate Vue to export excel table Operate Vue to export excel table

20 Apr 2018

This time I will introduce to you how to use Vue to export an excel table. What are the precautions for using Vue to export an excel table? The following is a practical case, let's take a look.

See all articles