anthropics / anthropics/skills

xlsx skill: presentation gotchas — merge banner cells (fill doesn't overflow) and escape & in headers/footers

Aberta
#1,440 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
176k
Forks
20.8k
Merge médio
7h 21min
PRs com merge (30d)
5

Descrição

## Summary

The `xlsx` skill (`skills/xlsx/SKILL.md`) gives solid guidance on data and formula correctness (recalc, zero-error checks, conventions), but it doesn't mention a couple of openpyxl **presentation** gotchas that silently produce visually broken output. Both are within the skill's existing scope (authoring xlsx with openpyxl). Reporting them with a minimal repro and fix. (This is separate from #584, which covers formula/OOXML compatibility.)

## Gap 1 — a filled title/banner cell does not overflow, so titles get clipped

A very common layout is a title in `A1` with a background fill, where the text is wider than column A and relies on overflow into the empty neighbor cells. Two issues:

- The **fill** only covers `A1`, so the colored banner does not span the width of the table below it.
- The overflow **text** is not shown reliably — it gets clipped at the cell boundary in many renderers, and it's worst when the first column is narrow (e.g. a numbering / `#` column only a few characters wide, which clips the title down to a few letters).

This is easy to miss because some viewers (e.g. Google Sheets) render the overflow on screen so it looks fine, while other renderers/exports clip it at the cell boundary.

**Fix** — merge the banner across the table width so both the fill and the text span correctly:

```python
from openpyxl.utils import get_column_letter
last = get_column_letter(ws.max_column)
ws.merge_cells(f"A1:{last}1") # title banner
ws.merge_cells(f"A2:{last}2") # subtitle, if any
```

A one-line note in the formatting section — "for a title/banner that spans multiple columns, merge the cells; a fill and long text do not overflow reliably" — would prevent this.

## Gap 2 — `&` in headers/footers is a field-code escape character

`&` starts a field code in Excel header/footer strings (`&C` = center section, `&L` / `&R` = left / right section, `&P` = page number, `&D` = date, etc.). A literal `&` in footer/header text is therefore misinterpreted:

```python
ws.oddFooter.left.text = "Revenue & Costs" # "&C" is read as the center-section code
```

renders as `Revenue ` on the left, with everything after `&C` pushed into the center section. A literal ampersand must be doubled:

```python
ws.oddFooter.left.text = "Revenue && Costs" # renders "Revenue & Costs"
```

Worth a one-line note wherever header/footer text is shown.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.