This commit is contained in:
JaguarJack
2021-05-14 08:36:45 +08:00
parent 66673a0714
commit f03421008a
2 changed files with 15 additions and 16 deletions

View File

@@ -12,18 +12,18 @@ use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
class Factory
{
public static function make($type)
public static function make($type, $spreadsheet)
{
if ($type === 'xlsx') {
return app(Xlsx::class);
return app(Xlsx::class)->setSpreadsheet($spreadsheet);
}
if ($type === 'xls') {
return app(Xls::class);
return new Xls($spreadsheet);
}
if ($type === 'csv') {
return app(Csv::class);
return (new Csv($spreadsheet))->setUseBOM('utf-8');
}
throw new FailedException(sprintf('Type [%s] not support', $type));