gayhub
k9606/kxcel
安裝
$ composer require k9606/kxcel
使用
use K9606\Kxcel\Kxcel;
$sourceDatas = [
[
'id' => 1,
'name' => '黃蜂女',
'gender' => '女',
'specialty' => '變化',
'address' => '新澤西',
'professional' => '復聯成員',
],
[
'id' => 2,
'name' => 'k9606',
'gender' => '男',
'specialty' => '無',
'address' => '天府新區',
'professional' => '復聯成員',
],
[
'id' => 3,
'name' => '蜘蛛俠',
'gender' => '男',
'specialty' => '靈敏',
'address' => '皇后區',
'professional' => '復聯成員',
],
];
$sourceDataKeysAndColumnNames = [
'name' => '姓名',
'gender' => '性別',
'address' => '所在地',
];
$fileName = 'excel';
$kxcel = new Kxcel();
$kxcel->export($sourceDatas, $sourceDataKeysAndColumnNames, $fileName);
請求:
引數 |
必選 |
型別 |
註釋 |
---|
$sourceDatas |
true |
array |
源資料 |
$sourceDataKeysAndColumnNames |
true |
array |
列值在 $sourceDatas 對應鍵與列名, 例如 ['name' => '姓名'] |
$fileName |
false |
string |
待匯出的檔名, 預設為 'excel' |
響應:
use K9606\Kxcel\Kxcel;
$filePath = './kxcel.xlsx';
$x = ['B' => 2];
$y = ['C' => 3];
$kxcel = new Kxcel();
$kxcel->import($filePath, $x, $y);
請求:
引數 |
必選 |
型別 |
註釋 |
---|
$filePath |
true |
string |
excel 檔案路徑 |
$x |
true |
array |
開始讀取點的列與行座標, [ 列 => 行 ] |
$y |
true |
array |
結束讀取點的列與行座標, 同上 |
響應:
[
[
"女",
"新澤西"
],
[
"男",
"天府新區"
]
]
基於
PHPOffice/PhpSpreadsheet
overtrue/package-builder
License
MIT