Skip to content

fix(xlsx): render requested screenshot range - #257

Open
Hanxcellent wants to merge 1 commit into
iOfficeAI:mainfrom
Hanxcellent:fix/issue-246-xlsx-screenshot-range
Open

fix(xlsx): render requested screenshot range#257
Hanxcellent wants to merge 1 commit into
iOfficeAI:mainfrom
Hanxcellent:fix/issue-246-xlsx-screenshot-range

Conversation

@Hanxcellent

Copy link
Copy Markdown

Summary

  • pass xlsx screenshot cell ranges into the HTML renderer in both one-shot and resident paths
  • extend the rendered sheet grid through the requested range corner before clipping
  • reuse the existing xlsx range parser while preserving element clips such as /Sheet1/chart[1]

Fixes #246

Root cause

CaptureClipped resolves an xlsx range through its two corner cells. The HTML renderer only emitted cells through the sheet's computed data/drawing extent, so when the requested lower-right corner was outside that grid it did not exist in the DOM. The crop union then contained only the surviving upper-left corner and collapsed to that cell, excluding the chart and the rest of the requested area.

On current main, the default full-sheet screenshot already renders this repro chart. The remaining reproducible defect is the --range path when the requested range extends past the generated grid.

Validation

Repro workbook: populated cells in A1:B13 plus a floating chart starting at D1, then:

officecli view repro.xlsx screenshot \
  --range "Sheet1!A1:J20" \
  -o range.png

Observed result:

Version PNG dimensions Content
current main 120 x 40 only A1; chart omitted
this branch 1182 x 800 full A1:J20 range and chart

Additional checks:

# Existing element clip still works: 710 x 680
officecli view repro.xlsx screenshot --range '/Sheet1/chart[1]' -o chart.png

# Existing in-grid cell range is unchanged: 238 x 520
officecli view repro.xlsx screenshot --range 'Sheet1!A1:B13' -o cells.png

dotnet build src/officecli/officecli.csproj -c Release

The build succeeds with the pre-existing nullable warning in ExcelHandler.SheetShift.cs.

Copilot AI review requested due to automatic review settings July 22, 2026 07:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

XLSX sheet screenshot omits floating charts and clips to the first populated cell

2 participants