I got some problems in my data download csv, i want [object Object] change to string in file csv. but i have try code the result is undefined.
this is my JSON format, i only take one example data
[
{
"id": 117,
"code": "RR123",
"dueDate": "2018-06-25T09:51:00",
"isActive": true,
"inspectors": {
"id": 67,
"employeeNumber": "18001",
"name": "Larks Anderson",
"isActive": true
},
"questioners": {
"id": 63,
"code": "PI190",
"name": "Inspeksi Door",
"isActive": true,
"questionerDetails": [
{
"id": 124,
"questionDetail": "",
"isActive": true
}
]
}
},
]
This is my code in component.ts
//Button CSV
getcsvFile() {
this.workorderService.getAllWorkOrder().subscribe(data => {
this.allpagingData = [];
let questionerlabel: any;
for (let index in data) {
console.log(data[index].questioners);
//i use this to change the [object Object], but the result is undefined in csv
for (let ai in data[index].questioners) {
questionerlabel = data[index].questioners[ai].name;
console.log(questionerlabel);
}
this.allpagingData.push({
"code": data[index].code,
"inspectors": data[index].inspectors,
"questioners": questionerlabel,
"dueDate": data[index].dueDate,
"isActive": data[index].isActive
});
}
var option = {
fieldSeparator: ',',
quoteStrings: '"',
decimalseparator: '.',
showLabels: true,
showTitle: true,
headers: ['WO Code' , 'Inspectors', 'Questioner', 'Date', 'Status']
}
new Angular2Csv(this.allpagingData, 'WorkOrder Report', option)
});
}
so how to change [object Object] to string?
