SMART Plan — [Core] Excel file support for bulk imports
Part of the import/export epic: #85. See also: #139 (import catalogs/pricelists), #140 (import products from CSV/Excel), #141 (import clients).
Specific
Ensure that the Filament ImportAction used across modules (Products, Clients, etc.) accepts .xlsx files in addition to CSV, using Filament's built-in Excel support via maatwebsite/laravel-excel. An Excel file with the same column structure as the CSV template should import identically.
Measurable
- The
ImportAction on ListProducts, ListRelations, etc. accepts .xlsx MIME types.
- An Excel file with 100 valid rows inserts exactly 100 records.
- Invalid rows report the same validation errors as their CSV counterparts.
Achievable
- Add
maatwebsite/laravel-excel as a Composer dependency if not already present.
- In each module's
Importer class, specify accepted file types: ->acceptedFileTypes(['text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']).
- Confirm that Filament's
ImportAction row processing works identically for both file types.
- Add a PHPUnit test that uploads a
.xlsx file and asserts the import count.
Relevant
Many companies manage their data in Excel rather than CSV. Requiring a CSV conversion before import adds friction during onboarding and data migration.
Time-bound
Sprint 6.
Arrange · Act · Assert
// Modules/Products/Tests/Feature/ProductsTest.php
#[Test]
public function it_imports_products_from_an_excel_file(): void
{
/* Arrange */
// Create a minimal .xlsx file with a header row and 2 data rows
$file = UploadedFile::fake()->create('products.xlsx', 10, 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
/* Act */
$component = Livewire::actingAs($this->user)
->test(ListProducts::class, ['tenant' => Str::lower($this->company->search_code)])
->callAction('import', ['file' => $file]);
/* Assert */
$component->assertSuccessful();
}
SMART Plan — [Core] Excel file support for bulk imports
Specific
Ensure that the Filament
ImportActionused across modules (Products, Clients, etc.) accepts.xlsxfiles in addition to CSV, using Filament's built-in Excel support viamaatwebsite/laravel-excel. An Excel file with the same column structure as the CSV template should import identically.Measurable
ImportActiononListProducts,ListRelations, etc. accepts.xlsxMIME types.Achievable
maatwebsite/laravel-excelas a Composer dependency if not already present.Importerclass, specify accepted file types:->acceptedFileTypes(['text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']).ImportActionrow processing works identically for both file types..xlsxfile and asserts the import count.Relevant
Many companies manage their data in Excel rather than CSV. Requiring a CSV conversion before import adds friction during onboarding and data migration.
Time-bound
Sprint 6.
Arrange · Act · Assert