SheetXL - v1.0.2
    Preparing search index...

    Function useCellValue

    • Binds a cell's value like useState: returns the value and a setter, and re-renders when the value changes, whether from the setter, the grid, or a recalculation.

      Type Parameters

      • T extends Scalar = Scalar

        The expected value type. This is not checked or converted: an empty cell is null, and a cell can hold any type.

      Parameters

      • target: CellRangeTarget | null | undefined

        The workbook or sheet to read from, or null while there is none.

      • address: Address

        The cell's address. A larger range binds its top-left cell.

      • Optionaloptions: CellRangeHookOptions

        Listener options, and an optional onChange that receives each change event.

      Returns [T | null, (value: T | null) => void]

      The value, or null while target is null, and a setter that does nothing until there is a target.

      The setter writes the value as-is: text is never parsed, so '=1+1' is stored as text rather than as a formula. To write formulas or styles, use useCell.

      const [customer, setCustomer] = useCellValue<string>(sheet, 'A4');
      return <input value={customer ?? ''} onChange={(e) => setCustomer(e.target.value)} />;