export datatable to excel angular 7
import { Component } from '@angular/core';
import { ExcelService } from './services/excel.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'exportExcelInAngular';
dataOfFootballers: any = [{
playerName: 'Cristiano Ronaldo',
playerCountry: 'Pourtgal',
playerClub: 'Juventus'
},
{
playerName: 'Lionel Messi',
playerCountry: 'Argentina',
playerClub: 'Barcelona'
},
{
playerName: 'Neymar Junior',
playerCountry: 'Brazil',
playerClub: 'PSG'
},
{
playerName: 'Tonni Kroos',
playerCountry: 'Germany',
playerClub: 'Real Madrid'
},
{
playerName: 'Paul Pogba',
playerCountry: 'France',
playerClub: 'Manchester United'
}];
constructor(private excelService:ExcelService){
}
exportAsXLSX():void {
this.excelService.exportAsExcelFile(this.dataOfFootballers, 'footballer_data');
}
}