← All runbooks
jettyio / json-to-excel★ Featured · worked examples

JSON → Excel

Given (a) an empty Excel template (.xlsx) whose cells already carry the document's structure — section labels, column headers, row labels — and placeholder cells for the data, and (b) a JSON file describing the values to insert, produce a filled copy of the…

agent claude-codemodel claude-sonnet-4-6snapshot python312-uv-officeeval programmatic10 stepsv1.0.0

Deploy JSON → Excel to your jetty.io

One-click installs this runbook into a collection on your Jetty account. You can run it from the Spot dashboard, schedule it, or pipe inputs in via the API.

Run time2–4 mins
Headline outputfilled_workbook.xlsx

Runs on Jetty's managed sandbox. No setup. Free for your first 10 runs.

Worked examples · 3

Real runs, real outputs.

The shape of the run

10 steps · start to finish.

  1. 1
    Step 1

    Environment Setup

    python -m pip install --quiet openpyxl beautifulsoup4 lxml
    mkdir -p "{{results_dir}}"
    
    # Resolve inputs from /app/assets (uploaded files land there)
    TEMPLATE="$(ls /app/assets/*.xlsx 2>/dev/null | head -1)"
    DATA="$(ls /app/assets/*.json 2>/dev/null | head -1)"
    NOTES="$(ls /app/assets/*.md 2>/dev/null | head -1)"
    echo "template=$TEMPLATE"; echo "data=$DATA"; echo "notes=${NOTES:-<none>}"
    [ -s "$TEMPLATE" ] || { echo "ERROR: no template .xlsx in /app/assets"; exit 1; }
    [ -s "$DATA" ]     || { echo "ERROR: no data .json in /app/assets"; exit 1; }
    

  2. 2
    Step 2

    Read & Apply Notes (if present)

    If a notes .md exists, read it before touching the workbook and extract structured rules: intentional blanks, dropdown/validation caveats (write only an accepted option, drop free text), sheets to…

  3. 3
    Step 3

    Load & Classify — build the placement plan

    wb = openpyxl.load_workbook(TEMPLATE) — keep formulas (data_only=False). 2. Load the fill data JSON. 3. For every cell in each touched sheet, classify it (store a cell_class map): - formula — value…

  4. 4
    Step 4

    Fill the Workbook

    Process fills sorted by (sheet, top_row, top_col). For each:

  5. 5
    Step 5

    Overflow Handling

    Under alert, never call insert_rows/insert_cols; dimensions must equal the template's. Truncate the value to fit, attach an openpyxl.comments.Comment to the first destination cell (OVERFLOW: 12 rows…

  6. 6
    Step 6

    Save & Self-Verify

    wb.save("{{results_dir}}/filled_workbook.xlsx") 2. Reopen the saved file — openpyxl.load_workbook(...) must not raise. 3. Spot-check 5 placed fills: read back the destination and confirm a non-empty…

  7. 7
    Step 7

    Evaluate Outputs

    Assign each fill a status:

  8. 8
    Step 8

    Iterate on Errors (max 3 rounds)

    For any FAIL: read the captured error, apply the matching Common Fix, retry just that fill, re-evaluate. Repeat at most 3 times; after that keep FAIL and surface it in summary.md.

  9. 9
    Step 9

    Write Executive Summary

    Write {{results_dir}}/summary.md:

  10. 10
    Step 10

    Write Validation Report

    Write {{results_dir}}/validation_report.json: