Worksheet Class
A stable sheet identity. Access never activates a worksheet. Feature collections share the existing worksheet identity and lifecycle validation.
Package: @txtextcontrol/tx-sheet-control-server. Version: 2.0.0.
Related workbook object-model type, returned through the server control. Obtain it from its owning workbook or collection; it is not a required browser-package import.
Constructor
new Worksheet(workbook, id)
| Parameter | Type | Optional | Description |
|---|---|---|---|
workbook | Workbook | No | Value matching workbook's declared type and the owning object's validation rules. |
id | string | No | Stable identity in the owning document/collection. |
Returns: Worksheet.
Members
Properties
| Property | Description |
|---|---|
| charts | The charts value of Worksheet. |
| columns | The columns value of Worksheet. |
| drawings | The drawings value of Worksheet. |
| id | The id value of Worksheet. |
| name | The name value of Worksheet. |
| names | The names value of Worksheet. |
| The print value of Worksheet. | |
| protection | The protection value of Worksheet. |
| rows | The rows value of Worksheet. |
| tabColor | Persisted sRGB tab color, or null for the default appearance. |
| tables | The tables value of Worksheet. |
| validation | The validation value of Worksheet. |
| viewport | The viewport value of Worksheet. |
| workbook | The workbook value of Worksheet. |
Methods
| Method | Description |
|---|---|
| addSparklines | Adds sparklines using A1 data/location ranges in one undoable sheet-scoped transaction. |
| cell | Create an A1 or zero-based coordinate cell handle. |
| clearSparklines | Removes sparklines in an A1 destination range (or all when omitted), retaining source cells. |
| duplicate | Duplicates this worksheet with distinct table identities/names, preserving cells and formatting. |
| getSparklineGroups | Reads detached sparkline definitions on this sheet without activating it. |
| move | Reorders this worksheet within its group; index is zero-based. |
| range | Create an A1 range handle. |
| remove | Remove this worksheet. |
| rename | Rename the sheet while preserving identity and qualified cell references. |
| setTabColor | Sets/clears the tab color in one undoable operation; rejects colors outside #RRGGBB. |
| updateSparklineGroup | Updates an existing group by stable ID; invalid or stale handles reject before mutation. |
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 createWorksheetReport(control) {
const book = control.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
pivotTables — Configure and refresh worksheet pivot tables.