Cell Class
A worksheet-bound scalar cell handle. Literal text, entered input and calculated values remain distinct. Cell features are returned as detached snapshots; mutations remain undoable.
Package: @txtextcontrol/tx-sheet-control. Version: 2.0.0.
ES module import: import { Cell } from '@txtextcontrol/tx-sheet-control';.
Constructor
new Cell(sheet, ref)
| Parameter | Type | Optional | Description |
|---|---|---|---|
sheet | Worksheet | No | Value matching sheet's declared type and the owning object's validation rules. |
ref | string | No | Value matching ref's declared type and the owning object's validation rules. |
Returns: Cell.
Members
Properties
| Property | Description |
|---|---|
| address | The address value of Cell. |
| bounds | The bounds value of Cell. |
| cellType | The cellType value of Cell. |
| columnCount | The columnCount value of Cell. |
| comments | The comments value of Cell. |
| displayStyle | The displayStyle value of Cell. |
| displayText | The displayText value of Cell. |
| formula | The formula value of Cell. |
| hyperlink | The hyperlink value of Cell. |
| input | The input value of Cell. |
| note | The note value of Cell. |
| picture | The picture value of Cell. |
| richText | The richText value of Cell. |
| rowCount | The rowCount value of Cell. |
| sheet | The sheet value of Cell. |
| style | The style value of Cell. |
| value | The value value of Cell. |
| values | The values value of Cell. |
Methods
| Method | Description |
|---|---|
| clear | Clear content and/or formatting. |
| copyTo | Copy cells within the same workbook using the selected paste mode in one undoable operation. |
| fillTo | The fillTo operation of Cell. |
| format | Apply a nested/flat style patch to the whole range. |
| formatText | Zero-based UTF-16 offsets, matching JavaScript and .NET string indices. |
| merge | Merge the range; across merges each row separately. |
| read | Read flat address/text/value/display/style records. |
| removePicture | Remove the embedded cell picture. |
| setCellType | The setCellType operation of Cell. |
| setFormula | Write an explicit formula; leading equals sign is required. |
| setFormulas | Write explicit formulas. |
| setHyperlink | The setHyperlink operation of Cell. |
| setInput | Parse entered content like typing in the editor. |
| setInputs | Write entered-content strings. |
| setNote | The setNote operation of Cell. |
| setNoteBounds | Sets/clears unzoomed note geometry in one undo operation; requires an existing note. |
| setPicture | Embed a PNG/JPEG inside the cell. |
| setRichText | Write literal text containing independently styled runs. |
| setText | Write literal text, preserving leading zeros and leading equals signs. |
| setValidation | The setValidation operation of Cell. |
| setValue | Write a literal JSON scalar. |
| setValues | Write a typed matrix of matching dimensions. |
| unmerge | Remove intersecting merges. |
Examples
Use a fresh workbook. Create and format the sample data, apply this API and retain the returned document or result in your application. In the browser pass editor.workbook; in Node.js pass the server control.
function createCellReport(book) {
const sheet = book.sheets.at(0);
sheet.cell('A1').setText('October invoice');
sheet.cell('A1').format({
fontFamily: 'Liberation Sans',
fontSize: 16,
bold: true,
textColor: '#ffffff',
fillColor: '#163b63',
});
sheet.columns.at(0).setWidth({ pixels: 240 });
sheet.range('B8:B9').setValues([[120], [80]]);
sheet.cell('B10').setFormula('=SUM(B8:B9)');
sheet.range('B8:B10').format({ numberFormatCode: '#,##0.00', fontSize: 11 });
return sheet;
}
See Also
barcode — Reads the cell barcode settings, or undefined for a cell without a barcode.
setBarcode — Displays a barcode while retaining the underlying value or formula. Omit options to remove only the barcode.