search
HomePHP LibrariesOther librariesPHP class to export excel table
PHP class to export excel table

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<?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 classphp export data to excel class

25Jul2016

php export data to excel class

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

18Jul2017