我有一個包含多張作業表的 excel,但我只想閱讀一個單行作業表:

我的問題是我有多張紙,而且順序不一樣或頁數不一樣。然后,我必須在我的匯入類(laravel import)上按名稱識別作業表。
這是我的匯入類:
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\WithEvents;
class ExecutedUPS implements WithMultipleSheets, WithEvents
{
private $nameSheetUPS = "LMS - F";
public function sheets(): array
{
$sheets = [];
//doesn't work for me
if($event->getSheet()->getTitle() === $this->nameSheetUPS){
$sheets[] = new SheetUPS();
}
return $sheets;
}
}
這里是我的課程“SheetUPS”:
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;
class SheetUPS implements ToCollection
{
/**
* @param Collection $collection
*/
public function collection(Collection $collection)
{
//this i know do
}
}
uj5u.com熱心網友回復:
您是否嘗試像檔案一樣按名稱選擇作業表?
//class ExecutedUPS
public function sheets(): array
{
return [
'LMS - F' => new SheetUPS(),
];
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/338659.html
標籤:擅长 拉拉维尔 上传文件 进口 laravel-excel
