I am struggling to export JSON data to Excel while maintaining the correct date format of 2020-07-30 07:31:45. Despite trying suggestions from a helpful post on sheetjs, I still couldn't get it right.
Here is an example of the JSON data:
{
"source": "internal",
"account": "Test",
"posted_at": new Date("2020-09-25T07:11:19.0000000"),
"content": "some content"
}
My current code snippet for exporting to Excel looks like this:
ws = XLSX.utils.aoa_to_sheet([[formattedQuery]]);
XLSX.utils.sheet_add_json(ws, json, { origin: -1, display: true }, { cellDates: true, dateNF: 'YYYYMMDD HH:mm:ss' });
var workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, ws, filename.substring(0, 29));
XLSX.writeFile(workbook, filename);
The issue arises when checking the saved Excel file, as seen here: https://i.stack.imgur.com/qHzF2.png