with one click
excel-test-data-generation
// Generate Excel test data with style-safe workbook mutations, merged-cell handling, and mapping verification for scenario-based test suites
// Generate Excel test data with style-safe workbook mutations, merged-cell handling, and mapping verification for scenario-based test suites
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | excel-test-data-generation |
| description | Generate Excel test data with style-safe workbook mutations, merged-cell handling, and mapping verification for scenario-based test suites |
Scope: This skill covers the how for Excel file operations — mutation tooling, merged-cell handling, column mapping inspection, and manifest.json reference format. It is designed to be loaded alongside the
generate-test-data-from-sampleprompt, which defines the what (business rules, scenario selection, and validation requirements).
Use this skill when: Creating or mutating
.xlsx/.xlsscenario files from a happy-path template where merged cells, formatting preservation, and accurate column mapping are required.
fs.copyFileSync — this is the only way to guarantee all formatting, styles, images, and merged cells are fully preserved.exceljs for targeted mutations only — open the copied file, apply only the required cell changes, then save back to the same path.xlsx (SheetJS) to write scenario files — it strips cell styles and reformats number cells, producing files that differ visually from the template even when data is unchanged.exceljs to re-read and re-write unchanged files — even a round-trip with no mutations will alter compression and may lose some style fidelity. Only process files that actually need mutations.fs.copyFileSync(TEMPLATE, outPath) // exact binary copy — preserves all styles
On Linux/macOS you can also use
cp. PowerShellCopy-Itemis equivalent on Windows.
Happypath file: stop here. Do not open it with exceljs at all. A pure binary copy is the correct output.const wb = new ExcelJS.Workbook()
await wb.xlsx.readFile(outPath) // open the copy, not the template
const ws = wb.getWorksheet('SheetName')
// ... apply mutations ...
await wb.xlsx.writeFile(outPath) // save back to same path
xlsx for read-only inspection):
const ExcelJS = require('exceljs')
const fs = require('fs')
// Step 1: binary-exact copy — preserves ALL formatting, styles, images, merges
fs.copyFileSync(TEMPLATE, outPath)
// Step 2: open the copy and apply only the required mutations
const wb = new ExcelJS.Workbook()
await wb.xlsx.readFile(outPath) // read from the copy
const ws = wb.getWorksheet('SheetName') // by name, not index
// exceljs uses 1-based row and column numbers
const headerRow = 45
const dataRow = 46
// Read a header cell
const headerCell = ws.getRow(headerRow).getCell(6) // column F
console.log('Header text:', headerCell.value)
// Clear a cell
ws.getRow(dataRow).getCell(6).value = null
// Set a cell value
ws.getRow(dataRow).getCell(3).value = '@123456' // column C
await wb.xlsx.writeFile(outPath) // save back to same path
exceljs uses 1-based column numbers: A=1, B=2, C=3, … Z=26. You can also pass the column letter as a string: getCell('K') or getCell(11) are equivalent.
// Happypath must be a bit-for-bit copy of the template — skip exceljs entirely
fs.copyFileSync(TEMPLATE, path.join(OUT_DIR, 'Happypath.xlsx'))
// ❌ DO NOT DO THIS — strips cell styles, inflates file size
const wb = XLSX.readFile(template, { cellStyles: true })
XLSX.writeFile(wb, outPath) // formatting lost even if nothing changed
Visual column layout can differ from actual data columns when templates use merged cells.
Document all field-to-column mappings in manifest.json using Excel column letters (A, B, C...), not numeric indices. For merged fields, list all participating columns (e.g. "commodity_code": ["L", "M"]).
RMS-GB-000216-xxx) in every data row (Column P, NIRMS Despatch No.), not once in a header region.xlsx (SheetJS) is acceptable for read-only inspection (mapping discovery, row counting, structure analysis) but must never be used to write scenario files. If exceljs cannot be installed, fall back to PowerShell/CLI binary copy for file creation and accept that targeted cell mutations cannot be applied without exceljs.