Skip to content

feat(excel): row-height autofit — row and sheet level - #388

Open
ylz92871-dotcom wants to merge 2 commits into
iOfficeAI:mainfrom
ylz92871-dotcom:pr/row-autofit-suggestions
Open

ylz92871-dotcom wants to merge 2 commits into
iOfficeAI:mainfrom
ylz92871-dotcom:pr/row-autofit-suggestions

Conversation

@ylz92871-dotcom

Copy link
Copy Markdown

What

autofit=true now works on rows, mirroring the column autofit:

officecli set data.xlsx '/Sheet1/row[7]' --prop autofit=true
officecli set data.xlsx /Sheet1 --prop autofit=true   # columns, then rows

Heuristic (no rendering engine): per cell, the wrapped line count is the sum over the cell's newline segments of ceil(display width / effective column width); the row height is max-lines × 15pt line pitch (11pt Calibri default), clamped to Excel's 15-409pt range, written with customHeight=true. The sheet-level form runs columns FIRST, then rows — the wrap estimate depends on the final column widths.

Why

Agents had column autofit but no row-height story: wrapped/CJK rows clipped with no recovery except hand-computed heights (a real 40-city KPI row needed two rounds of manual tuning). Excel's in-app autofit stays available for font-exact sizing; this gives the CLI a sane default.

Implementation

  • CalculateAutoFitHeight + AutoFitAllRows in ExcelHandler.Set.RowsCols.cs (next to the existing column autofit, reusing GetCellDisplayValue + ParseHelpers.EstimateTextWidthInChars, incl. its CJK width table).
  • set row[N] --prop autofit=true case in the row property switch; sheet-level autofit extended to rows after columns.

How to verify

set a 60-char string in A1, then:
officecli set data.xlsx '/Sheet1/row[1]' --prop autofit=true
  → row height 120pt (8 wrapped lines × 15pt), customHeight set
single-line row → 15pt
officecli set data.xlsx /Sheet1 --prop autofit=true
  → columns widen, rows re-fit after; validate clean

Local harness T-07: 4 suites / 9 assertions green (wrapped, CJK, single-line, sheet-level order, numeric_overflow suggestion intact).

What: 'autofit=true' now works on rows, mirroring the column autofit:
  officecli set data.xlsx '/Sheet1/row[7]' --prop autofit=true
  officecli set data.xlsx /Sheet1 --prop autofit=true   # columns, then rows

Heuristic (no rendering engine): per cell, wrapped lines = sum over the
cell's newline segments of ceil(display width / effective column width);
row height = max-lines × 15pt line pitch (11pt Calibri default), clamped
to Excel's 15-409pt range, written with customHeight=true. The sheet-level
form runs columns FIRST, then rows — the wrap estimate depends on the
final column widths.

Why: agents had column autofit but no row-height story — wrapped/CJK
rows clipped with no recovery except hand-computed heights (the 40-city
KPI row needed two rounds of manual tuning). Excel's in-app autofit
stays available for font-exact sizing.

How to verify:
  set a 60-char string in A1, then set '/Sheet1/row[1]' --prop autofit=true
  → row height 120pt (8 wrapped lines × 15pt), customHeight set
  single-line row → 15pt; sheet-level → columns widen, rows re-fit after
  validate clean
Local harness T-07: 4 suites / 9 assertions green (wrapped, CJK,
single-line, sheet-level order, numeric_overflow suggestion intact).
What: schemas/help/xlsx/row.json gains the `autofit` property declaration
for the row-level autofit this feature adds, and sheet.json documents the
sheet-level `autofit` (columns first, then rows) that previously existed
in code without a schema entry — matching column.json, which already
declares column autofit.

Why: schemas/help is the machine-readable help layer downstream automation
pins (plugins doctor validates props against it); a settable prop absent
from the schema reads as an unknown property to those consumers. Code
behavior and SKILL.md were already correct — this closes the help-layer gap.

How to verify:
  officecli help xlsx row | grep autofit     # entry renders
  officecli help xlsx sheet | grep autofit
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.

1 participant