npm install --save angular2-csv
For Angular [ 2,4,5 ] install old version:
npm install --save angular2-csv@0.2.5
In component.ts
import { Angular2Csv } from 'angular2-csv/Angular2-csv';
var data = [
{
name: "Test 1",
age: 13,
average: 8.2,
approved: true,
description: "using 'Content here, content here' "
},
];
new Angular2Csv(data, 'My Report');
For set headers try it =>
var head = ['name', 'age', 'average', 'etc'];
new Angular2Csv(data, 'My Report', { headers: (head) });
By using, this we hopefully modify our CSV file headers and title too exactly extract the same CSV as per need too
Links are here
https://www.npmjs.com/package/angular2-csv?activeTab=readme
https://www.npmjs.com/package/angular2-csv