All items used in this tutorial are explained in comments in the tutorial source Angular component files at ./src/app/start/04-quick-start-xlsx.component.html and ./src/app/start/04-quick-start-xlsx.component.ts
FastGrid library can be added to Angular project by
npm install fastgrid-angular
FastGrid library can be imported to Angular by
import { FastGridComponent } from "fastgrid-angular";
FastGrid as FastSheet can be created and shown in Angular app as tag <fast-grid [src]={sources} />
where sources is JavaScript object that defines grid layout and data, for example:
<fast-grid [src]="{ Cfg:{ SheetJs:1, Book:'QuickSheet' }, Body:[ { V:[1,2,3] }, { V:{A:4,B:5,C:6} } ] }" style="height:500px;" />
Created FastGrid object can be accessed by Angular @ViewChild like @ViewChild(FastGridComponent) grid! : FastGridComponent;
and this object can be used to invoke FastGrid API methods.
The FastGrid API event handlers can be assigned directly to <FastGrid/> tag like normal DOM events.
There are two ways of assigning events to FastGrid, input and output.
Input events are assigned as function object: [event] = "func" and can return value.
Output events are assigned as function call: (event) = "func($event)" and its return value is ignored.
The full simple Angular application using FastGrid API methods and events:
html:
<fast-grid [src]="src" (setValue)="onSetValue($event)" (click)="onClick($event)" (ready)="onReady($event)" [onEndEdit]="onEndEdit"
style="display:inline-block;max-width:100%"></fast-grid>
<button (click)="readValue()">Read value [1,A]</button>
<button (click)="changeValue(grid, 1, 'A', 'XXX')">Change value [1,A]</button>
ts:
import { Component, ViewChild } from "@angular/core";
import { FastGridComponent, type FastGridOutputEvent } from "fastgrid-angular";
@Component({ selector:"app-root", standalone:true, imports:[ FastGridComponent ], templateUrl:"./app.component.html" })
export class AppComponent {
readonly src = { Cfg:{ SheetJs:1, Book:'QuickSheet' }, Body:[ { V:[1,2,3] }, { V:{A:4,B:5,C:6} } ] };
@ViewChild(FastGridComponent) grid! : FastGridComponent;
readValue() : void { alert("Read value from cell [1,A]: "+this.grid.Get(1,"A")); }
changeValue(grid:FastGridComponent,row:TRow|string|number,col:TCol|string|number,val:any) : void { grid.Set(row,col,"",val,1); }
onSetValue(event:FastGridOutputEvent<"setValue">) : void { if(event.changes) console.log("Value set",event); }
onEndEdit: TFGrid["OnEndEdit"] = (grid,row,col,value,save) => {
if(!save||!value||!isNaN(Number(value))) return null;
grid.ShowMessage("Enter string?","Confirm",(but:string) => { if(but==="Ok") grid.EndEdit(1,1); }); return true;
};
onClick(event:FastGridOutputEvent<"click">) : void { if(event.row&&event.col) console.log("Clicked",event.row.id,event.col.id); }
onReady(event:FastGridOutputEvent<"ready">) : void { console.log("FastGrid "+event.grid.id+" is ready"); }
}
FastGrid documentation index and glossary is at https://www.treegrid.com/FDoc/Glossary.htm
Search FastGrid attributes, API methods and events in doc at https://www.treegrid.com/FDoc/SearchAttr.html
FastGrid is commercial software.
A license is required to use it in production.
Information about licensing is at https://www.treegrid.com/Licensing
License prices are at https://www.treegrid.com/Prices
Online purchase can be done in e-shop at https://www.treegrid.com/Purchase