CustomCellType.render Method
The render operation of CustomCellType.
Owner: CustomCellType. Package: @txtextcontrol/tx-sheet-control. Version: 2.0.0.
Syntax
render(context: CellRenderContext): string
Parameters
| Parameter | Type | Optional | Description |
|---|---|---|---|
context | CellRenderContext | No | Value matching context's declared type and the owning object's validation rules. |
Return Value
string.
Examples
Use a fresh sample workbook for this example. In the browser pass editor.workbook; in Node.js pass the server control. Document-bound objects are obtained from that same owner.
import type { Workbook } from '@txtextcontrol/tx-sheet-control';
function registerInvoiceLabel(book: Workbook) {
book.cellTypes.register('invoice_label', {
render: (context) => {
const text = String(context.value ?? '').replace(
/[&<>"]/g,
(character) => ({ '&': '&', '<': '<', '>': '>', '"': '"' })[character] ?? character,
);
return '<strong>' + text + '</strong>';
},
});
book.sheets.at(0).cell('B10').setCellType({ type: 'custom', renderer: 'invoice_label' });
}
Remarks
Use this member on an object from the current document. Reacquire document-bound handles after replacement/deletion. Validate arguments against the declared types and documented bounds; handle exceptions or rejected promises.