Cell Data
ReoGrid Web provides multiple ways to read and write cell values — from the high-level CellHandle API to low-level methods optimized for performance.
Accessing via CellHandle
Use worksheet.cell() to obtain a CellHandle and manipulate values.
const ws = grid.worksheet;
// Specify by A1 address
ws.cell('A1').value = 'Hello';
// Specify by row/column index (0-based)
ws.cell(0, 1).value = 'World';
// Read a value
const val = ws.cell('A1').value; // 'Hello'
Chain methods
setValue() is chainable. It can be combined with setStyle() and setFormat().
ws.cell('A1')
.setValue('Sales')
.setStyle({ bold: true, backgroundColor: '#dbeafe' })
.setFormat('#,##0');
Low-level API
For performance-critical code or use inside loops, use the direct methods.
// Set a value
ws.setCellInput(0, 0, 'Hello');
// Read a value
const raw = ws.getCellInput(0, 0); // Input value (string)
const num = ws.getCellNumericValue(0, 0); // Get as number
const text = ws.getDisplayText(0, 0); // Display text (with formatting applied)
// Check if a cell is numeric
const isNum = ws.isNumericCell(0, 0);
Bulk loading with loadCells()
Use loadCells() to set multiple cells at once.
ws.loadCells([
{ row: 0, column: 0, value: 'Name' },
{ row: 0, column: 1, value: 'Age' },
{ row: 1, column: 0, value: 'Alice' },
{ row: 1, column: 1, value: '30' },
]);
Entering formulas
When a value starts with =, it is interpreted as a formula.
ws.cell('C1').value = '=A1+B1';
ws.cell('C2').value = '=SUM(A1:B10)';
See Formula Engine for more details on formulas.
Performance tips
When updating a large number of cells, suspending rendering improves performance.
ws.suspendRender();
try {
for (let r = 0; r < 1000; r++) {
ws.setCellInput(r, 0, `Row ${r}`);
ws.setCellInput(r, 1, String(r * 100));
}
} finally {
ws.resumeRender(); // Resume rendering and redraw all at once
}
suspendRender() prevents the canvas from repainting after every change. Call resumeRender() when you are done to flush all updates in a single repaint.