PHP code example of szjcomo / excel

1. Go to this page and download the library: Download szjcomo/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/ */

    

szjcomo / excel example snippets


$obj1 = new Excel(['path'=>'./']);
$callbackClass = new ExcelCallback();
$field = [
	'id'=>['name'=>'序号'],
	'uname'=>['name'=>'学生姓名','callback'=>[$callbackClass,'unameHandler']],
	'add_time'=>['name'=>'报名时间','callback'=>[$callbackClass,'addTimeHandler']],
];
$data = [
	['id'=>1,'uname'=>'szjcomo','add_time'=>time()]
];
$result = $obj1->field($field)->data($data)->export('456.xlsx');
print_r($result);

$obj = new Excel();
$result = $obj->import('123.xls');
print_r($result);