TX Sheet Control

Worksheet Class

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. Version: 2.0.0.

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

Constructor

new Worksheet(workbook, id)
ParameterTypeOptionalDescription
workbookWorkbookNoValue matching workbook's declared type and the owning object's validation rules.
idstringNoStable identity in the owning document/collection.

Returns: Worksheet.

Members

Properties

PropertyDescription
chartsThe charts value of Worksheet.
columnsThe columns value of Worksheet.
drawingsThe drawings value of Worksheet.
idThe id value of Worksheet.
nameThe name value of Worksheet.
namesThe names value of Worksheet.
printThe print value of Worksheet.
protectionThe protection value of Worksheet.
rowsThe rows value of Worksheet.
tabColorPersisted sRGB tab color, or null for the default appearance.
tablesThe tables value of Worksheet.
validationThe validation value of Worksheet.
viewportThe viewport value of Worksheet.
workbookThe workbook value of Worksheet.

Methods

MethodDescription
addSparklinesAdds sparklines using A1 data/location ranges in one undoable sheet-scoped transaction.
cellCreate an A1 or zero-based coordinate cell handle.
clearSparklinesRemoves sparklines in an A1 destination range (or all when omitted), retaining source cells.
duplicateDuplicates this worksheet with distinct table identities/names, preserving cells and formatting.
getSparklineGroupsReads detached sparkline definitions on this sheet without activating it.
moveReorders this worksheet within its group; index is zero-based.
rangeCreate an A1 range handle.
removeRemove this worksheet.
renameRename the sheet while preserving identity and qualified cell references.
setTabColorSets/clears the tab color in one undoable operation; rejects colors outside #RRGGBB.
updateSparklineGroupUpdates 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(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