I post this here because I have a problem with my excel file when I try to read it. The excel is a time-table from where I work and I'd like to be able to upload it on my website and the treat the data. Here is what the excel looks like : Visual of the timetable excel and when you watch inside the box there is just the hour written with the format HH:MM:SS as shown here : Show of what are in the boxes. So I upload my excel via an input and I get it clearly and have no problem with it. Then I give it to a function where I use the XLSX package and try to treat the data but the problem is that instead of a raw text showing the hour (which I could then treat easily) I get these weirds float numbers which I don't even know the logic behind how it's calculated.What I get after the excel go through XLSX package Moreover, you can clearly see here that not all the hours are converted to these floats. Here is my code :
getFile(ev) {
let workBook = null;
let jsonData = null;
const reader = new FileReader();
const file = ev;//.target.files[0];
console.log(file);
reader.onload = (event) => {
const data = reader.result;
workBook = XLSX.read(data, { type: 'binary', raw:true, WTF:true});
console.log(workBook);
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);
}
reader.readAsBinaryString(file);
}
So here I need your help I already tried putting all sort of options in the read function as shown in the documentation but it didn't make a change not even the raw option which I believed was the chosen one.I post this here as a last hope and pray someone will be able to help me. Have a nice day guys and good code !
Aucun commentaire:
Enregistrer un commentaire