Skip to content

Commit 69fb7d0

Browse files
Add docs about multiple sheet imports
1 parent 529153c commit 69fb7d0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.vuepress/3.1.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ module.exports = [
4040
'collection',
4141
'model',
4242
'importables',
43+
'multiple-sheets',
4344
'heading-row',
4445
'batch-inserts',
4546
'chunk-reading',

3.1/imports/multiple-sheets.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Multiple Sheets
2+
3+
When a file has multiple sheets, each sheet will go through the import object. If you want to handle each sheet separately, you'll need to implement the `WithMultipleSheets` concern.
4+
5+
The `sheets()` method expects an array of sheet import objects to be returned.
6+
7+
```php
8+
namespace App\Imports;
9+
10+
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
11+
12+
class UsersImport implements WithMultipleSheets {
13+
14+
public function sheets(): array
15+
{
16+
return [
17+
// Select by sheet index
18+
0 => new FirstSheetImport(),
19+
20+
// Select by sheet name
21+
'Sheet2' => new SecondSheetImport
22+
];
23+
}
24+
}
25+
```
26+
27+
The `FirstSheetImport` can implement concerns like `ToCollection`, `ToModel`, ...

0 commit comments

Comments
 (0)