
Angular Table Exporter (CdkTable Exporter)
This project is mainly for making CdkTable components exportable as excel files. cdk-table-exporter facilitates the common functionalities for CdkTable implementations abstracting the behavior that can change among different CdkTable implementations, see mat-table-exporter for angular material table export.
Getting Started
Install cdk-table-exporter if you are not using angular material in your project. In this case you have to implement your version of CdkTableExporter abstract class to use as your directive.
npm install cdk-table-exporter
After installing cdk-table-exporter import CdkTableExporterModule in your ngModules
You can find more detail under the corresponding title of Usage section
Usage
Will be updated soon
API
CdkTableExporter
Input/Output | Property | Type | Description |
---|
@Input | cdkTable | any | Template-referance of CdkTable that's to be exported |
@Input | exporterButton | any | Template-referance of the button that's used to trigger the export |
@Input | sheetName | string | Template-referance of CdkTable that's to be exported |
@Input | fileName | string | Template-referance of CdkTable that's to be exported |
@Input | hiddenColumns | Array<number> | The indexes of the columns that are not wanted in the excel file |
@Output | exportStarted | EventEmitter<void> | Event that's fired when the export started |
@Output | exportCompleted | EventEmitter<void> | Event that's fired when the export completed |
JsonExporterService
JsonExporterService is published in cdk-table-exporter project. CdkTableExporter employs this service, hence through inheritance MatTableExporterDirective does too.
exportExcel Method
Exports excel file by employing xlsx sheetjs
Parameter | Type | Description |
---|
header | any | Any json object that holds the header information of the exported excel file aka the first row of the excel |
rows | Array<any> | Any json array that will be the rows of the exported excel |
fileName | string | Exported excel file's name |
sheetName | string | The name of the sheet that keeps the exported data |
hiddenColumns | Array<string> | Properties that are wanted to be hidden, i.e. id, createdDate, auditable properties etc. |
Licence
Apache-2.0