Dashboard Viewer
When readers should explore a dashboard but not change it, host it in a viewer. Set dashboardMode: 'viewer' when you create the browser control to publish a dashboard-focused experience. The viewer retains permitted filtering, chart interaction, drill navigation and source-row inspection, and hides the authoring controls.
Create a Viewer
The following code creates the browser control as a viewer in the element host and loads a TXWB document, the workbook format that retains dashboards:
const viewer = new Spreadsheet(host, { dashboardMode: 'viewer', height: 'fill',
fontCatalogURL: '/assets/sheet/fonts/catalog.json' });
await viewer.ready;
await viewer.load(txwbBytes, StreamType.InternalWorkbookFormat);
The code works as follows:
- Spreadsheet creates the browser control. The option dashboardMode set to
'viewer'selects the viewer policy; the other value,'editor', is the default.heightandfontCatalogURL, the URL of the deployed font catalog, are set as for the editor. - Spreadsheet.ready resolves once the control has initialized its font picker and the initial document fonts.
- Spreadsheet.load loads the bytes
txwbBytesof a TXWB document. StreamTypeInternalWorkbookFormatis the format of TXWB.
The same option is available in the Angular options, as dashboardMode, and for Razor as TXSheetControlOptions.DashboardMode = "viewer", the property TXSheetControlOptions.DashboardMode.
The policy is fixed for the lifetime of the mounted control. Recreate the control to change it.
How the Saved Mode Differs From the Hosting Policy
A dashboard has a saved mode, and the control has a hosting policy. They are separate settings:
- The saved mode. A dashboard's saved
designorviewmode, the property Dashboard.mode, controls integrated authoring and viewing in an editor. - The viewer policy. The mount-only viewer policy presents dashboards saved in design mode as a viewer too. It is host configuration rather than saved workbook content.
What the Viewer Hides
Worksheet authoring, add commands and dashboard tab editing are unavailable in the viewer UI, and the authoring ribbon tab selection area is hidden. Loading a document cannot re-enable those controls. With no usable dashboard loaded, the viewer shows an empty state instead of exposing worksheet authoring.
Keep the Data Authorized
Programmatic host APIs remain available in the viewer to load documents, refresh data or manage permitted views.
Important
Not a Data-Security Boundary. Because the host APIs remain available, viewer mode is not a data-security boundary. Send only authorized worksheet and source data to the browser, and enable source-row access deliberately.
Prepare the Document and Test the Viewer
- The document. Save a TXWB with the intended active dashboard and filter defaults.
- The assets. Keep the font and language assets available, as for the editor.
- The tests. Test narrow containers, empty results, date formatting and disabled source data.
Offer Parameters and Metric Choices
Numeric parameters let readers model a scenario without writing to spreadsheet cells. Define an ID, display name, value and optional inclusive bounds/step or a list of named numeric choices. Use @parameterId as the right operand of a calculation. The viewer shows an input and range slider, or a choice dropdown.
dashboard.update({ parameters: [
{ id: 'growth', name: 'Growth Multiplier', value: 1.1,
minimum: 0.8, maximum: 1.4, step: 0.05 }
] });
dashboard.updateWidget('revenue', {
query: { sourceId: 'sales', measures: [
{ field: 'Revenue', aggregation: 'SUM', alias: 'Revenue' }
], calculations: [
{ alias: 'Forecast', operation: 'multiply', left: 'Revenue', right: '@growth' }
] },
kpi: { measure: 'Forecast', comparisonMeasure: 'Revenue' }
});
dashboard.setParameter('growth', 1.2);
setParameter rejects nonfinite or out-of-range values without partially changing the workbook. Parameters belong to the dashboard and override same-named defaults in its queries. A chart mark can also select a numeric parameter when its action is parameter and parameterId identifies the configured control.
Give a widget metrics to offer complete alternative queries and number formats. setMetric(widgetId, metricId) applies the selected query. A Metric dropdown appears in the card. Switching from revenue to units should also switch the number format; currency formatting does not convert units.
Export a Dashboard
Choose Export PDF in the viewer toolbar, or save with an explicit dashboard ID. The PDF uses the saved theme, gradients, fonts, charts, KPI comparisons and active reporting context. Browser animations are not exported. PDF branding follows the configured license and export path. TXWB remains the format for editable dashboard definitions; XLSX does not store dashboards.
const bytes = await editor.save(StreamType.PDF, {
pdf: { dashboardId: dashboard.id, dashboardWidth: 1440, dashboardPage: 'fit' }
});
const url = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }));
const link = document.createElement('a');
link.href = url;
link.download = 'sales-dashboard.pdf';
link.click();
setTimeout(() => URL.revokeObjectURL(url), 5000);
StreamType comes from the public package (or TXTextControl.TXSheetControl in a script-tag integration). fit creates one dashboard-sized page. print paginates using the workbook's paper size and printable area; a card taller than the printable page can span pages. dashboardWidth accepts 480–4096 CSS pixels. Compact dashboards before exporting when their saved height would exceed 16,384 pixels.
For an SVG image, call await dashboard.renderSvg({ width: 1440 }). This is a detached visualization; store or display the returned SVG through your application's normal export controls. Use the licensed PDF export when you need an evaluation-marked document.
Use the Same Features in Angular
Import the component from @txtextcontrol/tx-sheet-control/angular. After the component's existing ready event supplies the editor, use editor.workbook.dashboards with the same TypeScript definitions as a JavaScript editor. Theme changes, parameters and drill-through do not require a second dashboard package or a different data model. Keep editor access inside the ready callback, and release application subscriptions when the component is destroyed.
Read a Dashboard on a Narrow Screen

The viewer stacks cards while retaining their saved desktop placements. Changing the viewport does not rewrite the dashboard or the worksheet data.
Bind Angular Controls to a Dashboard Parameter
The Angular component below creates a forecast card when the editor is ready. Its application button changes the dashboard parameter, so the displayed forecast updates without changing the spreadsheet revenue values.
import { Component } from '@angular/core';
import { TXSheetControlComponent } from '@txtextcontrol/tx-sheet-control/angular';
import type { Dashboard, Spreadsheet } from '@txtextcontrol/tx-sheet-control';
({
selector: 'app-performance',
standalone: true,
imports: [TXSheetControlComponent],
template: `<button type="button" (click)="applyScenario()">Apply 20% Growth</button>
<tx-sheet-control [options]="options" (ready)="onReady($event)" />`
})
export class PerformanceComponent {
readonly options = { rows: 20, columns: 8, height: 600 };
private dashboard?: Dashboard;
onReady(editor: Spreadsheet): void {
const book = editor.workbook;
const sheet = book.sheets.at(0);
sheet.range('A1:B3').setValues([
['Region', 'Revenue'], ['Europe', 42000], ['Americas', 38000]
]);
book.analytics.setSource({ id: 'sales', name: 'Sales', sheetId: sheet.id,
range: 'A1:B3', hasHeaderRow: true });
const dashboard = book.dashboards.add('Revenue Forecast');
dashboard.applyTheme('light-2');
dashboard.update({ mode: 'view', parameters: [
{ id: 'growth', name: 'Growth Multiplier', value: 1.1, minimum: 0.8, maximum: 1.4 }
] });
dashboard.addWidget({
id: 'forecast', type: 'kpi', title: 'Revenue Forecast',
placement: { x: 0, y: 0, width: 6, height: 5 },
query: { sourceId: 'sales', measures: [
{ field: 'Revenue', aggregation: 'SUM', alias: 'Revenue' }
], calculations: [
{ alias: 'Forecast', operation: 'multiply', left: 'Revenue', right: '@growth' }
] },
kpi: { measure: 'Forecast', comparisonMeasure: 'Revenue', target: 100000 },
format: { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }
});
this.dashboard = dashboard;
book.activeView = { type: 'dashboard', id: dashboard.id };
}
applyScenario(): void {
this.dashboard?.setParameter('growth', 1.2);
}
}
The initial forecast is $88,000. The button changes it to $96,000, with a $16,000 comparison against the source total. The component stores the dashboard handle from the current editor instance; reacquire handles if your application replaces the workbook.
Next Steps
- Deployment Overview: serve the editor script, stylesheet, fonts and language files the viewer needs.
- Filters and Drill-Down: see what readers can filter and drill into in the viewer.
- Licensing: check which license mode the viewer runs in, and configure a signed license where you have one.