PHP code example of utf6 / phalapi-excel

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

    

utf6 / phalapi-excel example snippets

 
$data = [
    ['name' => '张三', 'password' => 'qwa3la'],
    ['name' => '李四', 'password' => 'vdf45s']
];

$filename    = "用户信息.xlsx";
$headArr     = array("用户名", "密码");

\PhalApi\DI()->excel->exportExcel($filename, $data, $headArr, 'json');
 
$data = \PhalApi\DI()->excel->importExcel("./test.xlsx");
//返回
$data = [
    [
        '张三',
        '男'
    ]
];

$keys = ['name', 'sex'];
$data = \PhalApi\DI()->excel->importExcel("./test.xlsx", $keys);
//返回
$data = [
    [
        'name' => '张三',
        'sex' => '男'
    ]
];
composer 
$di->excel = function() {
    return new \utf6\phalapiExcel\Lite();
};