I'm using ExcelJs
in my Angular 7
app, where I have a function to import excel file. The problem is when I console.log
the data from the worksheet the date formats are wrong for e.g. the cell contains 2021.11.30 12:00:00
but in the log it shows 44530.5
.
here is the code for importing the file:
let workBook = null;
let jsonData = null;
const reader = new FileReader();
const file = ev.target.files[0];
reader.onload = (event) => {
const data = reader.result;
workBook = XLSX.read(data, { type: 'binary' });
jsonData = workBook.SheetNames.reduce((initial, name) => {
const sheet = workBook.Sheets[name];
initial[name] = XLSX.utils.sheet_to_json(sheet);
return initial;
}, {});
const dataString = JSON.stringify(jsonData);
console.log('data: ', dataString); <-- this shows the data from worksheet
document.getElementById('output').innerHTML = dataString.slice(0, 30000).concat("....");
// this.setDownload(dataString);
}
reader.readAsBinaryString(file);
}
In the worksheet the cell is set to Date. Any ideas what can I do to fix the issue with the wrong date format?