Initial commit for the Angular part. We are nowhere yet.

This commit is contained in:
Amritanshu
2019-06-14 00:32:34 +05:30
parent 1a1fa7881d
commit d59c60e81d
123 changed files with 3748 additions and 374 deletions

View File

@ -0,0 +1,18 @@
import {Injectable} from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ToCsvService {
constructor() {
}
toCsv(headers: any, data: any[]): string {
const header = Object.keys(headers);
const replacer = (key, value) => value === null ? '' : value;
const csv = data.map(row => header.map(fieldName => JSON.stringify(row[headers[fieldName]], replacer)).join(','));
csv.unshift(header.join(','));
return csv.join('\r\n');
}
}