'how can i export api nested array of data into excell file in react?
I am working on react e commerce website project and im trying to convert api nested array of data into excell file but im facing the issue. I'm able to get data into excell file in react.js but nested array of data is not showing in excell file???any one can please help me how can i fix it??
//im using this code for covert data into excell sheet
productdownloadFile=(datas=this.state.getlist)=>{
const fileType= "xlsx"
const ws= XLSX.utils.json_to_sheet(datas);
const wb={Sheets:{data:ws},SheetNames:["data"]};
const excelBuffer = XLSX.write(wb, {bookType:"xlsx", type:"array"});
const data = new Blob([excelBuffer], {type:fileType});
FileSaver.saveAs(data, "Product_List"+".xlsx")
}
//my api data is
{
"success": true,
"product": [
{
"id": 1,
"name": "laptop",
"description": "this is awesome product,you should byu it",
"photo": "https://buluckartphoto.s3.ap-south-1.amazonaws.com/download%20%283%29.jpeg",
"lableType": "Veg",
"status": "0",
"isTex": "1",
"GSTrate": 0.23,
"GSTtyp": "inclusive",
"HSNcode": "hsn525fgf",
"videoUpload": "https://buluckartphoto.s3.ap-south-1.amazonaws.com/download%20%283%29.jpeg",
"categoryId": 1,
"subCategoryId": 1,
"settingId": 1,
"createdAt": "2022-05-20T13:26:03.000Z",
"updatedAt": "2022-05-20T13:26:03.000Z",
"featureSetting": {
"recomendedProduct": true,
"deliverySlotStatus": true,
"loyaltyProgram": true,
"COD": true,
"showCOD": false,
"reccemendProductNo": 10
},
"productphotos": [],
"varientModels": [
{
"id": 2,
"sort": 1,
"sku": "htc",
"waightunitno": "250 gram",
"unit": "gram",
"mrp": 1450,
"discount": 450,
"price": 1000,
"stock": 5,
"minstock": 1,
"outofstock": "continew sell after thersold"
}
],
"reccomendProducts": [],
"category": {
"id": 1,
"name": "vegetable",
"photo": "https://buluckartphoto.s3.ap-south-1.amazonaws.com/images.jpeg"
},
"SubCategory": {
"id": 1,
"sub_name": "gold star2",
"photo": "https://buluckartphoto.s3.ap-south-1.amazonaws.com/download.jpeg"
}
}
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
