下面是将JSON导出到CSV的示例:
import { Angular7Csv } from 'angular7-csv/Angular7-csv';
var data = [
{
name: "Test 1",
age: 13,
average: 8.2,
approved: true,
description: [{"Status": "Pass", "TimeStamp": "2019-03-12 08:19:50", "UserID": "KG19932"}]
},
{
name: 'Test 2',
age: 11,
average: 8.2,
approved: true,
description: [{"Status": "Pass", "TimeStamp": "2019-03-12 08:19:50", "UserID": "KG19932"}]
},
{
name: 'Test 4',
age: 10,
average: 8.2,
approved: true,
description: [{"Status": "Pass", "TimeStamp": "2019-03-12 08:19:50", "UserID": "KG19932"}]
}
];
new Angular7Csv(data, 'My Report');
。csv文件下载成功,但在Description列中的值作为[object object]获得。我已经尝试过JSON.stringify和JSON.Parse但没有运气。有人对此有解决方案吗?
仅对说明进行字符串化
data.forEach(x=>{
x.description=JSON.stringify(x.description);
});
new Angular7Csv(data, 'My Report');