PHP code example of james-ban / import-export

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

    

james-ban / import-export example snippets



�滤器
$filter = new class implements PhpOffice\PhpSpreadsheet\Reader\IReadFilter {
   public function readCell($column, $row, $worksheetName = ''):bool
   {
        return $column === 'A';
   }
};

$reader = new ImportExporter\import\Excel([
	'filePath' => '/Users/burn/Desktop/维权.xlsx',
	'fileExtension' => 'xlsx',
	'formatFunction' => function($item) {//只读取第一个单元格
		return current($item);
	},
	'fistLine' => 0,
	'readFilter' => $filter//读取A列
]);


print_r($reader->readAll());



�出
$downloader = new ImportExporter\export\ExcelXml([
	'data' => [[1, '222'], [2, 'xxx']],
	'header' => ['id', 'name'],
	'filename' => 'test.xls',
]);
$downloader->download();