TX Sheet Control

Cell Class

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: Worksheet, ref: string): Cell
ParameterTypeOptionalDescription
sheetWorksheetNoValue matching sheet's declared type and the owning object's validation rules.
refstringNoValue matching ref's declared type and the owning object's validation rules.

Returns: Cell.

Members

Properties

PropertyDescription
addressThe address value of Cell.
boundsThe bounds value of Cell.
cellTypeThe cellType value of Cell.
columnCountThe columnCount value of Cell.
commentsThe comments value of Cell.
displayStyleThe displayStyle value of Cell.
displayTextThe displayText value of Cell.
formulaThe formula value of Cell.
hyperlinkThe hyperlink value of Cell.
inputThe input value of Cell.
noteThe note value of Cell.
pictureThe picture value of Cell.
richTextThe richText value of Cell.
rowCountThe rowCount value of Cell.
sheetThe sheet value of Cell.
styleThe style value of Cell.
valueThe value value of Cell.
valuesThe values value of Cell.

Methods

MethodDescription
clearClear content and/or formatting.
copyToCopy cells within the same workbook using the selected paste mode in one undoable operation.
fillToThe fillTo operation of Cell.
formatApply a nested/flat style patch to the whole range.
formatTextZero-based UTF-16 offsets, matching JavaScript and .NET string indices.
mergeMerge the range; across merges each row separately.
readRead flat address/text/value/display/style records.
removePictureRemove the embedded cell picture.
setCellTypeThe setCellType operation of Cell.
setFormulaWrite an explicit formula; leading equals sign is required.
setFormulasWrite explicit formulas.
setHyperlinkThe setHyperlink operation of Cell.
setInputParse entered content like typing in the editor.
setInputsWrite entered-content strings.
setNoteThe setNote operation of Cell.
setNoteBoundsSets/clears unzoomed note geometry in one undo operation; requires an existing note.
setPictureEmbed a PNG/JPEG inside the cell.
setRichTextWrite literal text containing independently styled runs.
setTextWrite literal text, preserving leading zeros and leading equals signs.
setValidationThe setValidation operation of Cell.
setValueWrite a literal JSON scalar.
setValuesWrite a typed matrix of matching dimensions.
unmergeRemove 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.

import type { Workbook } from '@txtextcontrol/tx-sheet-control';

function createCellReport(book: Workbook) {
    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