TypeScript
// app.component.ts
import { Component } from '@angular/core';
import * as Handsontable from 'handsontable';
import { HotTableRegisterer } from '@handsontable/angular';
@Component({
selector: 'app-root',
template: `
<div class="hot">
<hot-table [hotId]="id" [settings]="hotSettings"></hot-table>
</div>
<br>
<button (click)="swapHotData()">Load new data!</button>
`,
})
class AppComponent {
private hotRegisterer = new HotTableRegisterer();
id = 'hotInstance';
hotSettings: Handsontable.GridSettings = {
data: Handsontable.helper.createSpreadsheetData(40, 40),
//rowHeaders: true,
renderAllRows: true,
colHeaders: true,
allowColumnResize : true,
viewportColumnRenderingOffset: 27,viewportRowRenderingOffset: "auto",
colWidths: 50,
height: 450,
allowInsertColumn: false,allowInsertRow: true,allowRemoveColumn: false,allowRemoveRow: true,
autoWrapRow: false,autoWrapCol: false,
stretchH: 'all',
minSpareRows:true,
//maxRows: 5,
manualRowResize: true,manualColumnResize: true,
//columns: […],
//nestedHeaders:[…],
columns: [
{data: 'startDate',type: 'date',dateFormat: 'MM/DD/YYYY',readOnly: true},
{data: 'endDate',type: 'date',dateFormat: 'MM/DD/YYYY',readOnly: true},
{data: 'pmtDate',type: 'date',dateFormat: 'MM/DD/YYYY'},
{data: 'discountFactor',type:'numeric',className: "htRight",readOnly: true},
{data: 'prate',className: "htRight",readOnly: true},
{data: 'pfv',className: "htRight",readOnly: true},
{data: 'ppv',className: "htRight",readOnly: true},
{data: 'rrate',className: "htRight",readOnly: true},
{data: 'rfv',className: "htRight",readOnly: true},
{data: 'rpv',className: "htRight",readOnly: true},
{data: 'nfv',className: "htRight",readOnly: true},
{data: 'npv',className: "htRight",readOnly: true}
...