Vik*_*nvi 3 laravel maatwebsite-excel
我的 Excel 工作表中有多个工作表,我想获取当前处于活动状态的工作表的名称
我认为$event->getSheet()->getTitle()应该工作。您也可以使用事件。
class HImport1 implements ToCollection, WithHeadingRow, WithEvents
{
public $sheetNames;
public $sheetData;
public function __construct(){
$this->sheetNames = [];
$this->sheetData = [];
}
public function collection(Collection $collection)
{
$this->sheetData[] = $collection;
}
public function registerEvents(): array
{
return [
BeforeSheet::class => function(BeforeSheet $event) {
$this->sheetNames[] = $event->getSheet()->getTitle();
}
];
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2411 次 |
| 最近记录: |