I'm trying to convert the JSON in the following into an excel document using XLSX, but the nested array of dailyPointsArray is empty after conversion.
Tried code
const XLSX = require("xlsx");
const workSheet = XLSX.utils.json_to_sheet(attendanceData);
const workBook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workBook, workSheet, "attendance");
XLSX.write(workBook, { bookType: "xlsx", type: "buffer" });
XLSX.write(workBook, { bookType: "xlsx", type: "binary" });
XLSX.writeFile(workBook,"newExcel.xlsx");
attendanceData:[
{
workerId: '1230',
workerFullName: 'A',
workerDepartment: 'INFORMATION TECHNOLOGY',
workerDesignation: 'ASSISTANT MANAGER',
Location: 'locationA',
dailyPointsArray: [
{
inTime: '-',
Date: '23/03/2022',
outTime: '-',
Points: null,
createdAs: 'ABSENT'
},
{
inTime: '-',
Date: '24/03/2022',
outTime: '-',
Points: null,
createdAs: 'ABSENT'
}
],
total_duration: 0,
total_shift_points: 0
},
{
workerId: '1128',
workerFullName: 'B',
workerDepartment: 'INFORMATION TECHNOLOGY',
workerDesignation: 'MANAGER',
Location: 'LocationA',
dailyPointsArray: [
{
inTime: '-',
Date: '23/03/2022',
outTime: '-',
Points: null,
createdAs: 'ABSENT'
},
{
inTime: '-',
Date: '24/03/2022',
outTime: '-',
Points: null,
createdAs: 'ABSENT'
}
],
total_duration: 17,
total_shift_points: 2
},
]
Below is the excel file output
As you can see the column of dailyPointsArray is empty. I want to my excel file should be like the below image