TX Sheet Control

Range Class

Class

A worksheet-bound rectangular range for atomic bulk reads, writes, formatting and copy operations. Range operations retain protection, validation and shared transaction semantics.

Package: @txtextcontrol/tx-sheet-control. Version: 2.0.0.

ES module import: import { Range } from '@txtextcontrol/tx-sheet-control';.

Constructor

new Range(sheet: Worksheet, ref: string): Range
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: Range.

Members

Properties

PropertyDescription
addressThe address value of Range.
boundsThe bounds value of Range.
columnCountThe columnCount value of Range.
rowCountThe rowCount value of Range.
sheetThe sheet value of Range.
valuesThe values value of Range.

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 Range.
formatApply a nested/flat style patch to the whole range.
mergeMerge the range; across merges each row separately.
readRead flat address/text/value/display/style records.
setFormulasWrite explicit formulas.
setInputsWrite entered-content strings.
setValidationThe setValidation operation of Range.
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 createRangeReport(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