Repository navigation
Conversation
Two openpyxl presentation gotchas that silently produce broken output: - A background fill and long text in a title cell (e.g. A1) do not overflow across the row: the fill covers only A1 and the text clips at the cell edge in many renderers. Merging the row across the table makes both span. - openpyxl writes header/footer text straight into Excel's field-code language, where `&` introduces a field (&C, &P, ...). A literal `&` must be doubled to `&&`, or everything after it is dropped. Both verified against openpyxl 3.1.5 (serialized XML confirms the raw `&` lands in the code stream while `&&` stays literal). Refs anthropics#1440
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1440.
Two openpyxl presentation gotchas that silently produce visually broken output, both within the xlsx skill's existing scope. Added as two bullets to the "openpyxl gotchas" section.
1. A fill + long text does not overflow a cell reliably
A colored title/banner in
A1whose text is wider than column A relies on overflow into empty neighbors. But the fill covers onlyA1, and the overflow text clips at the cell edge in many renderers/exports (worst when the first column is narrow, e.g. a#column). Merging the row across the table makes both the fill and the text span:2. A literal
&in a header/footer must be doubledopenpyxl writes
oddHeader/oddFootertext straight into Excel's field-code language, where&introduces a field (&Ccenter,&Ppage number, ...). So"Revenue & Costs"loses everything after the&; write"Revenue && Costs".Verified (openpyxl 3.1.5)
PatternFillonA1leavesB1unfilled (fgColor 00000000), so the banner does not span;merge_cells("A1:E1")yields a single merged range across the row.left.text = "Revenue & Costs"serializes to<oddFooter>&LRevenue & Costs</oddFooter>— the lone&enters the code stream — while"Q1 && Q2"serializes with&&and renders a literal&. openpyxl does not auto-escape it.Scoped to a two-bullet note; happy to expand into an example if the maintainers prefer.