Range 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
| 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: Range.
Members
Properties
| Property | Description |
|---|---|
| address | The address value of Range. |
| bounds | The bounds value of Range. |
| columnCount | The columnCount value of Range. |
| rowCount | The rowCount value of Range. |
| sheet | The sheet value of Range. |
| values | The values value of Range. |
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 Range. |
| format | Apply a nested/flat style patch to the whole range. |
| merge | Merge the range; across merges each row separately. |
| read | Read flat address/text/value/display/style records. |
| setFormulas | Write explicit formulas. |
| setInputs | Write entered-content strings. |
| setValidation | The setValidation operation of Range. |
| 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.
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;
}