Cell References
Enable Excel-style cell references with a single prop. Column letter headers (A, B, C...) appear above the header row, row numbers show in the left gutter, and a name box in the toolbar displays the active cell reference (e.g. "A1", "C15").
Live Demo
The live demo above shows Radix UI styling (lightweight default). The same feature renders through the Fluent UI package with its native components.
Quick Example
- React
import { OGrid } from '@alaarab/ogrid-react-radix';
const columns = [
{ columnId: 'name', name: 'Name' },
{ columnId: 'age', name: 'Age', type: 'numeric' as const },
{ columnId: 'email', name: 'Email' },
{ columnId: 'department', name: 'Department' },
{ columnId: 'salary', name: 'Salary', type: 'numeric' as const,
valueFormatter: (v) => `$${Number(v).toLocaleString()}` },
];
function App() {
return (
<OGrid
columns={columns}
data={people}
getRowId={(item) => item.id}
cellReferences
defaultPageSize={25}
entityLabelPlural="people"
/>
);
}
The OGrid component has the same props across all React UI packages. To switch, just change the import:
- Radix (lightweight, default):
from '@alaarab/ogrid-react-radix' - Fluent UI (Microsoft 365 / SPFx):
from '@alaarab/ogrid-react-fluent'-- wrap in<FluentProvider>
How It Works
Setting cellReferences on the OGrid component enables three visual features together:
1. Column Letter Headers
A row of Excel-style column letters (A, B, C, ..., Z, AA, AB, ...) appears above the normal header row. These letters use base-26 encoding, matching the Excel convention:
| Columns | Letters |
|---|---|
| 1--26 | A--Z |
| 27--52 | AA--AZ |
| 53--78 | BA--BZ |
| 703+ | AAA, AAB, ... |
Click a column letter to select the whole column. Shift+click another letter, or drag across letters, to select a block of columns. The selection is an ordinary cell range, so copy, Delete, fill (Ctrl+D / Ctrl+R) and the status bar aggregates work on it. A merged cell the column touches grows the selection to include it, as in Excel.
2. Row Numbers
A numbered gutter column appears on the left side of the grid showing the absolute row number (1, 2, 3, ...). Row numbers are consistent across pages -- page 2 with a page size of 25 starts at row 26, not row 1.
Click a row number to select the whole row; Shift+click or drag across row numbers to select several rows.
You can show row numbers independently without the full cell references feature by using the showRowNumbers prop:
<OGrid
columns={columns}
data={people}
getRowId={(item) => item.id}
showRowNumbers
/>
This gives you the numbered gutter column without column letters or the name box.
3. Name Box
A small text field in the toolbar shows the active cell reference (e.g. "A1", "C15", "G3"). It updates when you click a cell or navigate with the keyboard.
The name box uses the column letter and absolute row number, so clicking the third column on row 5 of page 2 (with a page size of 10) shows "C15", not "C5".
You can also type into it to jump, as in Excel. Press Enter to select what you typed; Escape reverts and returns focus to the grid.
| Input | Selects |
|---|---|
B3 | One cell (it becomes the active cell) |
A1:C5 | A range; the top-left cell becomes active |
B:D (or C) | Whole columns |
2:4 | Whole rows |
A name from namedRanges | Its target range (case-insensitive) |
$ markers are ignored. A reference that isn't displayed (a hidden column, a row filtered out or on another page) or that names another sheet is rejected: the field is marked invalid and keeps your text so you can fix it. With formulas on, the formula bar's name box works the same way.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
cellReferences | boolean | false | Enable Excel-style cell references: column letter headers, row number gutter, and name box. Implies showRowNumbers. |
showRowNumbers | boolean | false | Show only the row number gutter column (no column letters or name box). Automatically enabled when cellReferences is true. |
Related
- Spreadsheet Selection -- cell-level selection with drag and shift-click
- Keyboard Navigation -- arrow key navigation updates the name box
- Toolbar -- the name box renders inside the toolbar strip