Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(sheets): add facade range list api#6932

Open
hexf00 wants to merge 1 commit into
devdream-num/univer:devfrom
feat/facade-get-range-list-apidream-num/univer:feat/facade-get-range-list-apiCopy head branch name to clipboard
Open

feat(sheets): add facade range list api#6932
hexf00 wants to merge 1 commit into
devdream-num/univer:devfrom
feat/facade-get-range-list-apidream-num/univer:feat/facade-get-range-list-apiCopy head branch name to clipboard

Conversation

@hexf00
Copy link
Copy Markdown
Member

@hexf00 hexf00 commented May 21, 2026

Summary

  • Add FRangeList facade support for applying the same operation to non-contiguous ranges.
  • Add FWorksheet.getRangeList(a1Notations) and FWorkbook.getRangeList(a1Notations); unqualified A1 notations resolve against the caller sheet / active sheet, while sheet-qualified A1 notations may target another sheet.
  • Add package-specific mixins for sheets-numfmt, sheets-data-validation, and sheets-note, so RangeList keeps Univer package boundaries while supporting number formats, data validations, checkboxes, and notes.

Google Apps Script RangeList Alignment

Reference: Google Apps Script RangeList / getRangeList(a1Notations) public reference. Google documents are licensed under CC BY 4.0 and sample code under Apache 2.0. This PR is an Apache 2.0 open-source implementation in Univer, using the public API surface as a migration-friendly compatibility reference while keeping Univer-style enums and package boundaries.

Supported in this PR:

  • FWorksheet.getRangeList(a1Notations: string[])
  • FWorkbook.getRangeList(a1Notations: string[]) for the active sheet
  • FRangeList.getRanges()
  • activate()
  • breakApart()
  • check() / uncheck() via sheets-data-validation facade mixin
  • clear() / clear(options) with Univer clear options
  • clearContent()
  • clearDataValidations() via sheets-data-validation facade mixin
  • clearFormat()
  • clearNote() via sheets-note facade mixin
  • insertCheckboxes() overloads and removeCheckboxes() via sheets-data-validation facade mixin
  • setBackground(color) / setBackgroundColor(color)
  • setBackgroundRGB(red, green, blue)
  • setBorder(type, style, color?) using Univer BorderType / BorderStyleTypes
  • setDataValidation(rule) using Univer data validation builder API
  • setFontColor(color)
  • setFontFamily(fontFamily)
  • setFontLine(fontLine)
  • setFontSize(size)
  • setFontStyle(fontStyle)
  • setFontWeight(fontWeight)
  • setFormula(formula) for A1 formulas
  • setHorizontalAlignment(alignment)
  • setNote(note) via sheets-note facade mixin
  • setNumberFormat(pattern) via sheets-numfmt facade mixin
  • setTextDirection(direction) using Univer TextDirection
  • setTextRotation(rotation)
  • setValue(value)
  • setVerticalAlignment(alignment)
  • setWrap(isWrapEnabled)
  • setWrapStrategy(strategy)

Follow-up TODOs from Google RangeList API surface:

  • setFormulaR1C1(formula) - Univer has R1C1 range parse/serialize utilities, but this API needs formula-string-level R1C1 reference conversion relative to each target cell before it can be exposed safely.
  • setShowHyperlink(showHyperlink) - no direct Univer facade/display-flag equivalent identified in the current hyperlink facade surface.
  • setVerticalText(isVertical) - no direct Univer sheets facade equivalent identified yet.
  • trimWhitespace() - implement separately with explicit value/rich-text/formula semantics.

Known differences from Google Apps Script:

  • getRangeList() currently documents and tests A1 notation. R1C1 formula support is intentionally not claimed in this PR.
  • activate() throws for cross-sheet range lists because active selection is a single-sheet UI state. Other operations may dispatch across sheet-qualified ranges by grouping or delegating per range.
  • setBorder() follows Univer's enum-based FRange.setBorder(type, style, color?) API instead of Google Apps Script boolean-edge overloads.
  • clear(options) follows Univer's current IFacadeClearOptions shape.
  • check() / uncheck() write the existing checkbox rule's checked/unchecked value and throw if the target contains non-checkbox data validation or mixed checkbox values.
  • removeCheckboxes() refuses to clear ranges that contain non-checkbox data validation, avoiding accidental deletion of unrelated validation rules.
  • setNote() / clearNote() target the top-left cell of each range, matching the existing sheets-note facade note model.
  • clearDataValidations(), setDataValidation(), checkbox methods, note methods, and number format methods are provided by package-specific facade mixins.

Implementation Notes

  • Low-risk grouped execution is used where existing commands already accept range arrays: border, merge break-apart, clear operations, and data validation operations.
  • Other style/value/formula operations currently delegate per FRange; they can be optimized later by extending the underlying command layer without changing the facade API.

Tests

  • pnpm --filter @univerjs/sheets typecheck
  • pnpm --filter @univerjs/sheets test src/facade/__tests__/f-range-list.spec.ts src/facade/__tests__/f-workbook.spec.ts
  • pnpm --filter @univerjs/sheets-numfmt typecheck
  • pnpm --filter @univerjs/sheets-numfmt test src/facade/__tests__/f-range.spec.ts
  • pnpm --filter @univerjs/sheets-data-validation typecheck
  • pnpm --filter @univerjs/sheets-data-validation test src/facade/__tests__/f-range.spec.ts
  • pnpm --filter @univerjs/sheets-note typecheck
  • pnpm --filter @univerjs/sheets-note test src/facade/__tests__/sheets-note.facade.spec.ts
  • pnpm exec eslint packages/sheets/src/facade/f-range.ts packages/sheets/src/facade/f-range-list.ts packages/sheets/src/facade/f-workbook.ts packages/sheets/src/facade/f-worksheet.ts packages/sheets/src/facade/index.ts packages/sheets/src/facade/__tests__/f-range-list.spec.ts packages/sheets/src/facade/__tests__/f-workbook.spec.ts packages/sheets-numfmt/src/facade/f-range-list.ts packages/sheets-numfmt/src/facade/index.ts packages/sheets-numfmt/src/facade/__tests__/f-range.spec.ts packages/sheets-data-validation/src/facade/f-range-list.ts packages/sheets-data-validation/src/facade/index.ts packages/sheets-data-validation/src/facade/__tests__/f-range.spec.ts packages/sheets-note/src/facade/f-range.ts packages/sheets-note/src/facade/f-range-list.ts packages/sheets-note/src/facade/index.ts packages/sheets-note/src/facade/__tests__/sheets-note.facade.spec.ts
  • git diff --check

@hexf00 hexf00 requested a review from VicKun4937 as a code owner May 21, 2026 16:33
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

View Deployment

📑 Demo (React@19) Demo (React@16) 📚 Storybook
🔗 Preview link 🔗 Preview link 🔗 Preview link

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 21, 2026

Playwright test results

passed  28 passed

Details

stats  28 tests across 12 suites
duration  7 minutes, 39 seconds
commit  a0c63c5
info  For more information, see full report and artifacts

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 75.26882% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.66%. Comparing base (0b99692) to head (a0c63c5).

Files with missing lines Patch % Lines
packages/sheets/src/facade/f-range-list.ts 64.81% 38 Missing ⚠️
.../sheets-data-validation/src/facade/f-range-list.ts 90.19% 5 Missing ⚠️
packages/sheets-numfmt/src/facade/f-range-list.ts 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6932      +/-   ##
==========================================
+ Coverage   60.60%   60.66%   +0.05%     
==========================================
  Files        2580     2584       +4     
  Lines      148313   148499     +186     
  Branches    33447    33464      +17     
==========================================
+ Hits        89888    90085     +197     
+ Misses      58425    58414      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hexf00 hexf00 force-pushed the feat/facade-get-range-list-api branch 3 times, most recently from 9cac6cc to e323f29 Compare May 21, 2026 17:07
@hexf00 hexf00 force-pushed the feat/facade-get-range-list-api branch from e323f29 to a0c63c5 Compare May 21, 2026 17:22
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.