how to export angular material cdk table to csv and pdf file in angular 2/4

1k views Asked by At

here is an angular material cdk table which needs to be exported in csv and pdf file.

<md-table #table [dataSource]="productDataSource" mdSort>
        <ng-container cdkColumnDef="Name">
            <md-header-cell *cdkHeaderCellDef md-sort-header><span mdTooltip="Click to Sort Column" mdTooltipPosition="above"> Prduct Name </span></md-header-cell>
            <md-cell *cdkCellDef="let product" (click)="detailForm($event)" [id]="product.Id"> {{product.Name}} </md-cell>
        </ng-container>
        <ng-container cdkColumnDef="ProductGuid">
            <md-header-cell *cdkHeaderCellDef md-sort-header><span mdTooltip="Click to Sort Column" mdTooltipPosition="above"> Product Guid </span></md-header-cell>
            <md-cell *cdkCellDef="let product" (click)="detailForm($event)" [id]="product.Id"> {{product.ProductGuid}} </md-cell>
        </ng-container>
        <md-header-row *cdkHeaderRowDef="displayedColumns"></md-header-row>
        <md-row *cdkRowDef="let row; columns: displayedColumns;" class="data-row"></md-row>
    </md-table>

I am using angular 4 and material design.

0

There are 0 answers