export excel with serial number
Hello, I want to add new Filament\Actions\Exports\ExportColumn field in my exporter that should display serial number of the records in excel.
My current code which prints 1 for every record, it isnt incrementing:
public static function getColumns(): array
{
$rowNumber = 1;
return [
ExportColumn::make('serial_number')
->label('SN.')
->state(function () use (&$rowNumber): string {
return $rowNumber++;
}),
ExportColumn::make('name'),
];
}
1 Reply
It wouldn't know to increment. You would need do it on the row count on the class, so
then