I have JSON Response coming from API. I want to export it to excel sheet in CSV format.
JSON Response:
[
{
"id": 13,
"context": "http://tempurl.org",
"details": [
{
"name": "test1"
},
{
"name": "test2"
}
],
"username": "testuser1",
"custName": "cap1"
},
{
"id": 14,
"context": "http://tempurl.org",
"details": [],
"username": "testuser2",
"custName": "cap2"
}
]
Here is a data of CSV that we need to get once it opens on export button click:
id context username custName name
13 http://tempurl.org testuser1 cap1 test1
13 http://tempurl.org testuser1 cap1 test2
14 http://tempurl.org testuser2 cap2
Previously I was using gridApi that was doing the csv download but it only works for a visible table whose data we want to export. But not for JSON as in my case.
There is no proper tutorial for the latest angular 7 that cab provide me the insight on how to do this.