[app.component.html]
<button ejs-button (click)="btnClicked()">ExcelExport</button>
<ejs-grid #grid [dataSource]='data' allowPaging='true'
[allowExcelExport]='true'>
<e-columns>
<e-column field='OrderID' headerText='Order ID' width='120' textAlign='Right' isPrimaryKey='true'></e-column>
<e-column field='OrderDate' headerText='Order Date' width='130' format="yMd" textAlign='Right'></e-column>
<e-column field='CustomerID' headerText='Customer ID' width='120'></e-column>
<e-column field='Freight' headerText='Freight' [allowGrouping]="false" width='120' format='C2' textAlign='Right'></e-column>
<e-column field='ShipCountry' headerText='Ship Country' width='150'></e-column>
</e-columns>
</ejs-grid>
-------------------------------------------------------------------------------------------------------------------------
[app.component.ts]
export class AppComponent {
public data: Object[];
@ViewChild('grid')
public grid: GridComponent;
public ngOnInit(): void {
this.data = orderDetails;
}
btnClicked(args): void {
this.grid.excelExport();
}
}
|
[app.component.html]
<img src="https://upload.wikimedia.org/wikipedia/commons/f/f9/Phoenicopterus_ruber_in_S%C3%A3o_Paulo_Zoo.jpg" style="width: 50px;
height: 50px;" (click)="btnClicked()">
<ejs-grid #grid [dataSource]='data' allowPaging='true'
[allowExcelExport]='true'>
<e-columns>
-----
</e-columns>
</ejs-grid>
---------------------------------------------------------------------------
[app.component.ts]
export class AppComponent {
public data: Object[];
@ViewChild('grid')
public grid: GridComponent;
public ngOnInit(): void {
this.data = orderDetails;
}
btnClicked(args): void {
const excelExportProperties: ExcelExportProperties = {
fileName: 'new.xlsx'
};
this.grid.excelExport(excelExportProperties);
}
}
|