TX Sheet Control

Workbook Class

Class

Licensed workbook model. Active-sheet methods use the selected worksheet; retained handles bind explicit sheets.

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 Workbook(options?: WorkbookOptions): WorkbookInstance
ParameterTypeOptionalDescription
optionsWorkbookOptions | undefinedYesSupported settings for this operation; omitted settings retain documented defaults.

Returns: WorkbookInstance.

Members

Properties

PropertyDescription
activeSheetIdThe activeSheetId value of Workbook.
activeSheetNameThe activeSheetName value of Workbook.
activeViewThe sole sheet or dashboard view displayed by the integrated editor.
analyticsWorkbook-wide deterministic data profiling, relationships and asynchronous queries.
autoExpandThe autoExpand value of Workbook.
calculationThe calculation value of Workbook.
cellTypesThe cellTypes value of Workbook.
columnsThe columns value of Workbook.
dashboardsIndependent first-class dashboard definitions, persisted by .txwb and .ods.
dateSystemThe dateSystem value of Workbook.
eventsThe events value of Workbook.
historyThe history value of Workbook.
maxColumnsThe maxColumns value of Workbook.
maxRowsThe maxRows value of Workbook.
namesThe names value of Workbook.
rowsThe rows value of Workbook.
searchThe search value of Workbook.
sheetsThe sheets value of Workbook.
userNameThe userName value of Workbook.

Methods

MethodDescription
addConditionalRuleAdds a validated active-sheet rule; returns its stable ID (maximum 200 rules).
addSparklinesActive-sheet sparkline operation; validated, persisted and undoable.
applyCellStyleApplies a named style to the active-sheet range in one undo operation.
batchThe batch operation of Workbook.
clearFiltersRemoves filter criteria while keeping the filter range.
clearSparklinesActive-sheet sparkline operation; validated, persisted and undoable.
consolidateConsolidates same-sheet ranges in one undo operation.
createCellStyleCreates a workbook-wide style; returns its stable ID.
createMailMergeTemplateThe createMailMergeTemplate operation of Workbook.
deleteConditionalRuleRemoves the active-sheet conditional rule in one undo operation.
ensureSizeThe ensureSize operation of Workbook.
getAutoFilterReturns the active-sheet filter as a detached snapshot.
getMailMergeThe getMailMerge operation of Workbook.
getSparklineGroupsActive-sheet sparkline operation; validated, persisted and undoable.
listConditionalRulesLists detached active-sheet conditional rules, optionally intersecting a range.
listNamedStylesLists detached workbook-wide named style definitions.
loadLoads XLSX/TXWB bytes or CSV/XML/JSON text/UTF-8 bytes atomically. Tabular formats replace the workbook with one worksheet.
mergeThe merge operation of Workbook.
onChangeThe onChange operation of Workbook.
previewConsolidatePreviews a bounded consolidation without modifying the destination.
previewRemoveDuplicatesPreviews retained/removed rows without changing data or history.
previewTextToColumnsPreviews splitting a single source column without writing cells.
recalculateThe recalculate operation of Workbook.
removeDuplicatesRemoves duplicates in the selected range in one undo operation.
saveSaves a snapshot with reusable format-specific options; PDF is save-only.
saveTextSaves CSV, XML or JSON text with flat settings. Omits a generated CSV BOM; UTF-8 byte limits/events still include it. Does not change the workbook or options.
setAutoFilterSets/removes the active-sheet filter; criteria are native validated filter definitions.
setFormulaProviderThe setFormulaProvider operation of Workbook.
setMailMergeThe setMailMerge operation of Workbook.
setThemeChanges the workbook's twelve native theme colors in one undo operation.
sortRangeSorts the active sheet in one undoable operation; rejects merged ranges and invalid keys.
textToColumnsApplies the split in one undo operation; rejects occupied targets unless overwrite is true.
updateCellStyleUpdates a named style; affected cells on every sheet inherit the update.
updateConditionalRuleUpdates the active-sheet rule with the given ID; rejects unknown IDs.
updateSparklineGroupActive-sheet sparkline operation; validated, persisted and undoable.

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 { ServerSheetControl } from '@txtextcontrol/tx-sheet-control-server';

function createWorkbookReport(control: ServerSheetControl) {
    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