anthropics / anthropics/skills
xlsx skill: presentation gotchas — merge banner cells (fill doesn't overflow) and escape & in headers/footers
- Ngôn ngữ chính
- Python
- Star
- 176k
- Fork
- 20.9k
- Merge trung bình
- 7 giờ 21 phút
- Pull request đã merge (30 ngày)
- 5
Mô tả
## 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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Open skills/xlsx/SKILL.md and find the formatting and header/footer guidance. Add a note explaining that title banners should merge across the table width because fills and long text do not overflow reliably, and that literal ampersands in header/footer text must be escaped by doubling them. Done means both openpyxl presentation gotchas and their fixes are documented in the existing skill scope.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- documentation
- Loại issue
- Tài liệu
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 85/100