Skip to content

Commit d3d5dd5

Browse files
GlennMpatrickbrouwers
authored andcommitted
Add documentation for WithCustomStartCell (SpartnerNL#69)
* Add documentation for WithCustomStartCell * Add code example
1 parent 070c315 commit d3d5dd5

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

3.1/exports/collection.md

+28
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,34 @@ class InvoicesExport implements FromCollection, WithStrictNullComparison
181181
}
182182
```
183183

184+
## Custom start cell
185+
The default start cell is _A1_. Implementing the `WithCustomStartCell` concern in your export class allows you to specify a custom start cell.
186+
187+
```php
188+
namespace App\Exports;
189+
190+
use App\Invoice;
191+
use Maatwebsite\Excel\Concerns\FromCollection;
192+
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
193+
194+
class InvoicesExport implements FromCollection, WithCustomStartCell
195+
{
196+
public function collection()
197+
{
198+
return Invoice::all();
199+
}
200+
201+
public function startCell()
202+
{
203+
return 'B2';
204+
}
205+
}
206+
```
207+
208+
:::warning
209+
`WithCustomStartCell` is only supported for `FromCollection` exports.
210+
:::
211+
184212
## Storing raw contents
185213

186214
If you want to receive the raw contents of the exported file, you can use the `raw()` method:

3.1/exports/concerns.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pageClass: no-toc
2323
|`Maatwebsite\Excel\Concerns\WithCustomCsvSettings`| Allows to run custom Csv settings for this specific exportable. | [Custom CSV Settings](/3.1/exports/custom-csv-settings.html) |
2424
|`Maatwebsite\Excel\Concerns\WithCharts`| Allows to run one or multiple PhpSpreadsheet Chart instances. | |
2525
|`Maatwebsite\Excel\Concerns\WithDrawings`| Allows to run one or multiple PhpSpreadsheet (Base)Drawing instances. | [Drawings](/3.1/exports/drawings.html) |
26-
|`Maatwebsite\Excel\Concerns\WithCustomStartCell`| Allows to specify a custom start cell. Do note that this is only supported for FromCollection exports. | |
26+
|`Maatwebsite\Excel\Concerns\WithCustomStartCell`| Allows to specify a custom start cell. Do note that this is only supported for FromCollection exports. | [Custom start cell](/3.1/exports/collection.html#custom-start-cell) |
2727
|`Maatwebsite\Excel\Concerns\WithPreCalculateFormulas`| Forces PhpSpreadsheet to recalculate all formulae in a workbook when saving, so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet viewer when opening the file. | |
2828

2929
### Traits

0 commit comments

Comments
 (0)