Skip to content

feat(xlsx): pictures and chart placeholders on sheets - #11

Merged
pierreneter merged 1 commit into
p10node:mainfrom
mkroemer:xlsx-drawings
Nov 17, 2026
Merged

pierreneter merged 1 commit into
p10node:mainfrom
mkroemer:xlsx-drawings

Conversation

@mkroemer

Copy link
Copy Markdown
Contributor

This shows the pictures on a spreadsheet's sheets, and puts a labeled box where a chart is. It is independent of the UI PRs (#4 to #10) and based on main; whichever lands second needs a small rebase in XlsxView.tsx, which I'll do.

A sheet's drawing part (xl/drawings/drawingN.xml) is read for its pictures and charts with their anchors: two cells, one cell and a size, or a position and a size. The new worker call xlsx.drawings(sheet) returns them, and the grid lays them over the cells, placed by the row and column axes. So a picture moves and grows with resized or hidden rows and columns, and the sheet extends far enough to reach every drawing.

A picture the browser can draw (PNG, JPEG, GIF, SVG, ...) is shown as itself, through the client's media URLs. A chart, and a picture in a format the browser cannot draw (EMF, WMF), is shown as a box of its size naming what is there: the chart's kind (column, bar, line, pie, ...) and its title. Shapes and text boxes are left out. Clicks go through to the cells below.

test/xlsx-drawings.test.ts checks that a sheet lists its pictures and charts with their anchors and leaves shapes out, and that a drawing placed by its cells moves and grows with them. bun run typecheck, bun test and the e2e suite pass in CI.

A follow-up PR draws the charts themselves as SVG in place of the placeholder.

🤖 Generated with Claude Code

A sheet's drawing part (xl/drawings/drawingN.xml) is read for its
pictures and charts with their anchors: two cells, one cell and a size,
or a position and a size. The new `xlsx.drawings(sheet)` call returns
them; the grid lays them over the cells, placed by the row and column
axes, so a picture moves and grows with resized or hidden rows and
columns, and the sheet extends far enough to reach every drawing.

A picture the browser can draw (PNG, JPEG, GIF, SVG, ...) is shown as
itself, through the client's media URLs. A chart, and a picture in a
format the browser cannot draw (EMF, WMF), is shown as a box of its
size naming what is there: the chart's kind (column, bar, line, pie,
...) and title. Shapes and text boxes are left out. Clicks go through
to the cells below.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@pierreneter pierreneter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, pictures on sheets are a welcome addition.

Approved. Typecheck and unit tests pass, and it merges cleanly together with #4, #5, #13 and #16. I checked the relationship handling against the recent fix for remote requests: external, absolute, //host, ../ and data: targets never become a URL, r:link is ignored, and SVG media is a blob in an <img>.

Follow-ups, none blocking:

  • An anchor row such as 3999999998 extends the row axis to 4e9 and the grid hangs. main already hangs the same way on <row r="4000000000">, so that one belongs to main and not to this PR; clamping corner() in src/core/xlsx/drawings.ts to 1,048,576 rows and 16,384 columns would still be right.
  • A group shows only its first picture, stretched over the whole group; crop and rotation are ignored.
  • Every picture is fetched on sheet open, also the ones off screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants