Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add another header with one row in Angular5Csv generated Csv in Angular5? #32

Open
fahad88 opened this issue Feb 27, 2019 · 0 comments

Comments

@fahad88
Copy link

fahad88 commented Feb 27, 2019

I have a custom component in Angular5 application named data-graph component. In that custom component i received data which i am exporting to Csv using Angular5Csv angular package which is downloading instantly on button click correctly. Here is that clicked function code from data-graph.component.ts

import { Angular5Csv } from 'angular5-csv/dist/Angular5-csv'
exportToCsv() { let fileName = this.sensors[0].meter.name + 'Sensors Report'; this.sensorsData.map(item => { if (item._id) { delete item._id; } item.Time = new Date(item.date).toLocaleString(); delete item.date; }) this.customData = this.sensorsData; let fields = Object.keys(this.customData[0]); var options = { fieldSeparator: ',', decimalseparator: '.', title: '', showLabels: true, showTitle: true, noDownload: false, headers: fields, }; new Angular5Csv(this.customData, fileName, options); let anotherCsv = new Angular5Csv(this.customData, fileName, options); }

This exports a csv with data and headers very correctly in this format :

 `F1      C1      P1        Time
 10.0   12.54    9.32   2/26/2019, 2:08:22 PM
 08.32  12.54    2.32   2/26/2019, 2:08:24 PM
 05.01  12.54    5.32   2/26/2019, 2:08:27 PM
 11.0   12.54    6.32   2/26/2019, 2:09:22 PM`

But i want to add another header with one row like this :

`Min     Max    Average
F1   05.01  11.0     09.32
C1   02.66  15.04    10.65
P1   2.32   6.32     3.44`

`F1      C1      P1        Time
10.0   12.54    9.32   2/26/2019, 2:08:22 PM
08.32  15.04    2.32   2/26/2019, 2:08:24 PM
05.01  04.33    5.32   2/26/2019, 2:08:27 PM
11.0   02.66    6.32   2/26/2019, 2:09:22 PM`

How can i achieve this result using angular5Csv?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant