openpyxl-merged-cell-safe-write

openpyxl-merged-cell-safe-write is a skill for Claude Code, Codex from HKUDS/OpenSpace. It costs 22 tokens per session (891 once invoked), scanned A, original, MIT.

A safe pattern for assigning values in merged cells when editing Excel spreadsheets with openpyxl, a Python spreadsheet library.

In plain words
What is it for?
Use it when creating formatted spreadsheet headings or other layouts that combine several cells into one.
Why use it?
It avoids errors that occur when a value is written to a merged cell instead of the merge range's top-left cell.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when creating formatted spreadsheet headings or other layouts that combine several cells into one.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hkuds/openspace/openpyxl-merged-cell-safe-write
About the project

OpenSpace is a skill-management layer for AI agents that stores, retrieves, evaluates, shares, and improves reusable workflows. It is intended for people using multiple coding agents who want skills to be reused and refined based on task outcomes. The catalogue provides 200 skills for use with OpenSpace and the agents it supports.

HKUDS/OpenSpace · 7,552 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add HKUDS/OpenSpace --skill openpyxl-merged-cell-safe-write
Clone the repo
git clone --depth 1 https://github.com/HKUDS/OpenSpace

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for openpyxl-merged-cell-safe-write

README.md
[![agentmods](https://agentmods.dev/badge/skills/hkuds/openspace/openpyxl-merged-cell-safe-write/github.svg)](https://agentmods.dev/skills/hkuds/openspace/openpyxl-merged-cell-safe-write)
Your own site
<a href="https://agentmods.dev/skills/hkuds/openspace/openpyxl-merged-cell-safe-write"><img src="https://agentmods.dev/badge/skills/hkuds/openspace/openpyxl-merged-cell-safe-write/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for openpyxl-merged-cell-safe-write

Your own site · 80×15
<a href="https://agentmods.dev/skills/hkuds/openspace/openpyxl-merged-cell-safe-write"><img src="https://agentmods.dev/badge/skills/hkuds/openspace/openpyxl-merged-cell-safe-write.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 22 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 891 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00022 $0.00891
Opus 5 $0.00011 $0.00445
Sonnet 5 $0.00004 $0.00178
Haiku 4.5 $0.00002 $0.00089

Measured 6d ago against content hash 2ada92ac5bcc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

openpyxl-merged-cell-safe-write scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

benchmarks/gdpval/skills/openpyxl-merged-cell-safe-write/SKILL.md · 127 lines

How it starts

The opening of the file, as written. The whole thing — 127 lines — stays where its author put it; the contents beside it link to each section on GitHub.

OpenPyXL Merged Cell Safe Write Pattern

Problem

When creating formatted spreadsheets with openpyxl, merging cells and then assigning values to them causes MergedCell errors. This is a common pitfall that can consume multiple failed iterations.

Core Rule

Always assign values to the top-left cell of a merge range BEFORE applying the merge, or avoid assigning to merged cells entirely after the merge is applied.

Correct Pattern

from openpyxl import Workbook

wb = Workbook()
ws = wb.active

# CORRECT: Set value first, then merge
ws['A1'] = 'Quarterly Revenue Report'  # Assign to top-left cell first
ws.merge_cells('A1:D1')                # Then apply merge

# Also set formatting after merge
ws['A1'].font = Font(bold=True, size=16)
ws['A1'].alignment = Alignment(horizontal='center')

Incorrect Pattern (Causes MergedCell Error)

# WRONG: Merge first, then assign value
ws.merge_cells('A1:D1')
ws['A1'] = 'Quarterly Revenue Report'  # This raises MergedCell error!

Step-by-Step Procedure

  1. Identify merge ranges you need for headers, titles, or grouped data
  2. Write values to the top-left cell of each range before merging
  3. Apply the merge using ws.merge_cells()
  4. Apply formatting (font, alignment, borders) to the top-left cell
  5. Verify by checking that only the top-left cell holds the value

Additional Guidelines

For Multiple Merged Regions

# Define all merges with their values
merges = [
    ('A1', 'D1', 'Quarterly Revenue Report'),
    ('A3', 'B3', 'Product'),
    ('C3', 'D3', 'Sales Data'),
]

for start_col, end_col, value in merges:
    cell_ref = f'{start_col}'  # Top-left cell
    ws[cell_ref] = value       # Set value first
    ws.merge_cells(f'{start_col}:{end_col}')  # Then merge

When Modifying Existing Merged Cells

If you need to update a value in an already-merged range:

# Get the top-left cell of the merged range
top_left = 'A1'  # Know your merge structure
ws[top_left] = 'New Value'  # Only modify the top-left cell

Read the full file on GitHub · 127 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 127 lines · 22 tokens per session scan A 2ada92ac5bcc

Subscribe to this mod's changes

openpyxl-merged-cell-safe-write is a skill published in the GitHub repository HKUDS/OpenSpace (7,552 stars, last pushed 27d ago), licensed MIT. It adds 22 tokens to every session and 891 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.