|
| 1 | +# Excel Parser |
| 2 | + |
| 3 | +A package for parsing and generating Excel files for NHS Notify supplier configuration data. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Parse Excel files containing supplier configuration data (PackSpecification, LetterVariant, VolumeGroup, Supplier, SupplierAllocation, SupplierPack) |
| 8 | +- Generate template Excel files with the correct sheet structure and headers |
| 9 | +- Validate parsed data against Zod schemas |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +### Parsing an Excel file |
| 14 | + |
| 15 | +```typescript |
| 16 | +import { parseExcelFile } from "@nhs-notify/excel-parser"; |
| 17 | + |
| 18 | +const result = parseExcelFile("./specifications.xlsx"); |
| 19 | + |
| 20 | +console.log(result.packs); // Record<string, PackSpecification> |
| 21 | +console.log(result.variants); // Record<string, LetterVariant> |
| 22 | +console.log(result.volumeGroups); // Record<string, VolumeGroup> |
| 23 | +console.log(result.suppliers); // Record<string, Supplier> |
| 24 | +console.log(result.allocations); // Record<string, SupplierAllocation> |
| 25 | +console.log(result.supplierPacks); // Record<string, SupplierPack> |
| 26 | +``` |
| 27 | + |
| 28 | +### Generating a template Excel file |
| 29 | + |
| 30 | +```typescript |
| 31 | +import { generateTemplateExcel } from "@nhs-notify/excel-parser"; |
| 32 | + |
| 33 | +// Generate a new template (fails if file exists) |
| 34 | +generateTemplateExcel("./specifications.template.xlsx"); |
| 35 | + |
| 36 | +// Force overwrite existing file |
| 37 | +generateTemplateExcel("./specifications.template.xlsx", true); |
| 38 | +``` |
| 39 | + |
| 40 | +## Required Excel Sheets |
| 41 | + |
| 42 | +The Excel file must contain the following sheets: |
| 43 | + |
| 44 | +1. **PackSpecification** - Pack specification definitions |
| 45 | +2. **LetterVariant** - Letter variant configurations |
| 46 | +3. **VolumeGroup** - Volume group definitions |
| 47 | +4. **Supplier** - Supplier information |
| 48 | +5. **SupplierAllocation** - Supplier allocation percentages per volume group |
| 49 | +6. **SupplierPack** - Mapping of suppliers to pack specifications |
| 50 | + |
| 51 | +See `EXCEL_HEADERS.md` for detailed column specifications. |
0 commit comments