Rows n’ Columns Docs
Visit HomepagePricing
  • Introduction
  • License
  • Demos
  • Getting started
    • Installation
    • Spreadsheet state
    • Headless UI
    • Imperative Spreadsheet API
    • Examples
  • ⚙️Configuration
    • Features
      • Data validation
      • Formula evaluation
      • Real-time data
      • Cell editors
      • Cell renderer
      • Structured Cell Renderer
      • Theming
      • Styling
      • Context menu
      • Localisation
      • Undo/Redo
      • Conditional formatting
      • Named ranges
      • Structured references
        • Schema based tables and columns
        • Calculated columns
      • Basic filter or Excel AutoFilter
      • Charts
      • Embedded content
      • Calculate on-demand
      • Drag and Drop
      • Pivoting and Grouping (Coming soon)
      • Tokenizer
      • Lazy loading/Infinite scrolling
      • OpenAI/Chat GPT Integration
      • Search
      • Formula protection
      • Autofill
      • Export canvas as image
    • Components
      • Canvas Grid
      • Toolbar
      • Sheet Tabs
      • Sheet Switcher
      • Sheet Status
      • Range Selector
      • Formula Input
      • Selection Input
      • SheetSearch
      • NamedRangeEditor
      • DeleteSheetConfirmation
      • TableEditor
      • Cell Format Editor
      • Conditional Format Editor
      • Data Validation Editor
      • Insert Link Editor
      • Insert Image Editor
    • API
      • Cell Data
      • Sheets
      • SpreadsheetProvider
      • useSpreadsheet
      • Modules
      • SheetCell
    • Using Spreadsheet with NextJS
    • Keyboard shortcuts
  • Collaboration
    • Real time collaboration
    • Yjs Collaboration
    • Supabase realtime Collaboration
  • Charts
    • Charts
    • Custom charts
  • Excel and Google sheets
    • CSV
    • Excel
    • Google sheets (Coming soon)
  • Functions
    • Named functions
    • Array formulas
  • Data persistence
    • Server side data persistence
    • React Query integration
  • Specifications
    • Browser support
    • Third party licenses
  • Support
    • Contact support
    • Report bugs
    • Feature requests
Powered by GitBook
On this page

Was this helpful?

  1. Configuration
  2. API

useSpreadsheet

useSpreadsheet exposes some of the internal API via hooks

Wrap your app in SpreadsheetProvider to use useSpreadsheet hook

import { SpreadsheetProvider, CanvasGrid, useSpreadsheet } from "@rowsncolumns/spreadsheet";

const MySpreadsheet = () => {
  const {
    makeEditable,
    canEditCell,
    cancelEditor,
    focusSheet,
    getCellBounds,
    getCellDimensions,
    getContentfulGridRangeAroundCell,
    getNamedRanges,
    getNextFocusableCell,
    getRowHeight,
    getSelectionsFromFormula,
    getTableColumnNames,
    getTableNames,
    onEditorKeyDown,
    scrollToCell,
    setEditorValue,
    submitEditor,
    updateSelectionStartEndReference,
    tokenizer,
  } = useSpreadsheet();
  return (
    <CanvasGrid />
  );
};

const App = () => (
  <SpreadsheetProvider>
    <MySpreadsheet />
  </SpreadsheetProvider>
);
API
Description

makeEditable

Manually trigger a cell to be in edit mode

canEditCell

Verify if a cell is editable, respects protected ranges

cancelEditor

Cancels edit mode

focusSheet

Trigger focus on the Spreadsheet

getCellBounds

Get relative position of a cell relative to container

getCellDimensions

Get dimension (x, y, width, height) of a cell

getContentfulGridRangeAroundCell

Get range around a specific cells that has content

getNamedRanges

Get all named ranges of a sheet

getNextFocusableCell

Get next available cell that can be focused. Skips hidden cells, rows and columns

getRowHeight

Returns row height of a rowIndex

getSelectionsFromFormula

Get all selections from text

getTableColumnNames

Helper function to retrieve table column names

getTableNames

Helper function to retrieve table names

onEditorKeyDown

Callback when user enters value in editor

scrollToCell

Scroll to a cell

setEditorValue

Imperatively set value in the editor

submitEditor

Submit value of a editor

updateSelectionStartEndReference

Internal function to update selection references

tokenizer

Tokenizer formulas to identify selections and structured references

flash

Flash a range of cells

PreviousSpreadsheetProviderNextModules

Last updated 5 months ago

Was this helpful?

⚙️