Set up repository with legacy .NET Framework 4.8 source (OLD/), new .NET 10 Blazor solution (NEW/), OpenSpec specifications, documentation, and project configuration.
4.4 KiB
Implement Excel Export
Summary
Implement the Excel export subsystem that generates multi-sheet Excel workbooks (.xlsx) containing search results and criteria documentation using the ClosedXML library on .NET 10. This phase provides an injectable IExcelExportService that transforms search data into formatted, protected spreadsheets with conditional sheet generation based on search options (MIS data extraction).
Scope
In Scope
IExcelExportServiceinterface andExcelExportServiceimplementationExcelExportOptionsconfiguration class with protection passwords- Search Criteria sheet generator with filter tables
- Search Results sheet generator with attribute-driven columns
- MIS Info sheet generator (conditional on ExtractMisData)
- Investigation sheet generator (conditional on ExtractMisData)
- Worksheet protection with configurable passwords
- Attribute-driven column configuration (
OutputColumnAttribute,OutputTableAttribute) - Data entry template generator for bulk upload
- Header cell formatting utilities
- Service registration extension method (
AddExcelExport) - Unit tests with xUnit, Shouldly, and NSubstitute
Out of Scope
- API endpoints for Excel download (Phase 8: web-api-auth)
- Search result storage/retrieval (Phase 6: search-processing)
- SignalR progress updates (Phase 8: web-api-auth)
- File system storage of exports (results stored as byte[] in database)
- Streaming exports for very large files (deferred to future optimization)
Motivation
The Excel export subsystem is a core deliverable of the JDE Scoping Tool. Users depend on well-formatted Excel reports containing:
- Complete search criteria documentation for audit trails
- Work order results with status, quantities, and inclusion reasons
- MIS (Manufacturing Information System) data for quality analysis
- Investigation data for router mismatch analysis
Migrating from EPPlus (which requires commercial license in v7+) to ClosedXML (MIT license) eliminates licensing concerns while maintaining comparable functionality.
Acceptance Criteria
IExcelExportService.GenerateAsync()produces valid .xlsx files- Workbooks contain correct sheets based on
ExtractMisDataflag:- Standard export: 2 sheets (Search Criteria, Search Results)
- Full export: 4 sheets (+ MIS Info, Investigation)
- All column definitions match legacy output exactly:
- Search Results: 19 columns with correct headers and formats
- MIS Info: 19 columns with wrapped text columns
- Investigation: 12 columns with date formatting
- Worksheet protection applied with correct passwords from configuration
- Filter tables use Light18 table style with Gainsboro headers
- Auto-fit columns with correct padding (15% for criteria, 30% for data)
- Wrapped text columns (Test Description, Tools & Gauges, Work Instructions) use fixed 65-character width
- Inclusion reason computed correctly from boolean flags
- Service registered correctly via
AddExcelExport()extension method - Unit tests achieve >90% code coverage
openspec validate implement-excel-export --strictpasses
Dependencies
| Phase | Dependency | Type |
|---|---|---|
| Phase 3: implement-domain-models | SearchModel, SearchResult, MisSearchResult, MisNonMatchSearchResult |
Required |
| Phase 6: implement-search-processing | Populated search results for testing | Soft dependency (can mock) |
Note: This phase can proceed in parallel with Phase 6 by mocking search results in tests. The SearchModel and result types must be defined first.
Risks
| Risk | Likelihood | Impact | Mitigation |
|---|---|---|---|
| ClosedXML API differences from EPPlus | Medium | Medium | Cross-reference ClosedXML documentation; create API mapping guide in design.md |
| Memory pressure with large exports | Low | High | Monitor memory usage; document streaming approach for future optimization |
| Protection password exposure | Low | Medium | Store passwords in configuration, document in security notes |
| Column order/format mismatch | Medium | High | Generate comparison spreadsheets; verify against legacy output |
Related Specs
excel-export/spec.md- Base specification for Excel export subsystemdomain-models/spec.md- Domain models including SearchModel and result typessearch-processing/spec.md- Search processing that produces results for export