I am making an Angular4 I have a button that converts data to a csv file with header. Now I want to do it the other way around, I want to upload a csv file. So for testing, I make an object and make a csv file from it, and then I want to click on a button and upload that file and get the same result.
I found an angular module to export csv, but I can't find one that does it the other way around. Can someone help me with that?
This is my code:
test.ts
import { Component, OnInit} from '@angular/core';
import { Angular2Csv } from 'angular2-csv/Angular2-csv';
import {Unit} from "../../../_shared/unit";
@Component({
moduleId: module.id,
templateUrl: 'test.component.html',
styleUrls: ['./test.css']
})
export class TestComponent implements OnInit {
ngOnInit() {}
public export() {
// Unit (id,name,description)
var data = [new Unit(1,"Unit1","This is unit 1!")];
var options = {
fieldSeparator: ';',
quoteStrings: '"',
decimalseparator: ',',
showLabels: true,
useBom: true
};
new Angular2Csv(data, "data", options);
}
public import(){}
}
test.html
<button (click)="export()">Download CSV</button>
<button (click)="import()">Upload CSV</button>