PHP code example of linyuee / excel

1. Go to this page and download the library: Download linyuee/excel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

linyuee / excel example snippets


//导出的数据
$data = array(
            ['id'=>1,'username'=>'test1','phone'=>'18881515151'],
            ['id'=>2,'username'=>'test2','phone'=>'18881515152'],
            ['id'=>3,'username'=>'test3','phone'=>'18881515153'],
        );
//标题
$sheettitle = array(  
            'id'=>'ID',
            'username'=>'答题人',
            'phone'=>'联系方式',
        );
//导出的数据和标题数组的key要一致
$excel = new \Linyuee\Excel\Export();
        $excel->setData($data)
            ->setFileName('问卷答题情况')
            ->setTitle($sheettitle)
            ->setStartIndex('B')
            ->setFileExt('csv')  //目前支持csv,xls,xlsx
            ->export();        
angular2html
$excel = new \Linyuee\Excel\Import();
        $data = $excel->setPath('/disk2/123.xlsx')->read();
        var_dump($data);