Excel::load($file->getRealPath())->get();
这将仅返回项,而不返回标头。
您可以使用以下命令获取文件标题:
$file = Excel::load($file->getRealPath())
$file->getTitle();
你也可以在单个工作表上调用getTitle((:
foreach ($file->get() as $sheet) {
echo $sheet->getTitle();
}
use MaatwebsiteExcelConcernsWithProperties;
class InvoicesExport implements WithProperties
{
public function properties(): array
{
return [
'creator' => 'Patrick Brouwers',
'lastModifiedBy' => 'Patrick Brouwers',
'title' => 'Invoices Export',
'description' => 'Latest Invoices',
'subject' => 'Invoices',
'keywords' => 'invoices,export,spreadsheet',
'category' => 'Invoices',
'manager' => 'Patrick Brouwers',
'company' => 'Maatwebsite',
];
}
}
试试这个