总账备注映射导入支持 --sheet 选择工作表(补京东网银钱包/淘系微信两处空列)
- account-ledger-remarks:import 新增 --sheet(序号或名称),默认仍读第一个工作表 - 用于导入分表2:京东 33 条(钱包页签项目)+ 天猫 25 条(wx… 微信项目),导入后两处空列即可按平台匹配出值
This commit is contained in:
parent
c04054ca0b
commit
9fdc1408b8
@ -13,7 +13,7 @@ use Throwable;
|
||||
*/
|
||||
class ImportAccountLedgerRemarks extends Command
|
||||
{
|
||||
protected $signature = 'account-ledger-remarks:import {path : xlsx/csv 文件} {--replace : 先清空再导入(默认按平台+账单项目覆盖)}';
|
||||
protected $signature = 'account-ledger-remarks:import {path : xlsx/csv 文件} {--sheet=1 : 工作表序号(从 1 开始)或名称} {--replace : 先清空再导入(默认按平台+账单项目覆盖)}';
|
||||
|
||||
protected $description = '导入账单项目对应的总账备注映射表';
|
||||
|
||||
@ -89,7 +89,20 @@ class ImportAccountLedgerRemarks extends Command
|
||||
if ($readerType === 'Csv') {
|
||||
$reader->setInputEncoding('UTF-8');
|
||||
}
|
||||
$sheet = $reader->load($path)->getActiveSheet();
|
||||
$book = $reader->load($path);
|
||||
$sheetOption = trim((string) $this->option('sheet'));
|
||||
if ($sheetOption !== '' && ctype_digit($sheetOption)) {
|
||||
$index = (int) $sheetOption - 1;
|
||||
if ($index < 0 || $index >= $book->getSheetCount()) {
|
||||
throw new \InvalidArgumentException('工作表序号超出范围:' . $sheetOption);
|
||||
}
|
||||
$sheet = $book->getSheet($index);
|
||||
} else {
|
||||
$sheet = $sheetOption === '' ? $book->getActiveSheet() : $book->getSheetByName($sheetOption);
|
||||
if ($sheet === null) {
|
||||
throw new \InvalidArgumentException('找不到工作表:' . $sheetOption);
|
||||
}
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$header = null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user