I'm trying to parse an excel document with XLSX(vuejs).
I have two columns with dateFormat(dd/mm/yy) in my excel document, I want to prevent problems and know when the dateFormat of a parsed cell is different from the setup. If someone changed manually the dateFormat of a cell in the excel file I want to know it when parsing it with my function and reformat. At the end, I want all my dates to be dd/mm/yy.
I don't know where to go from my function.
Here is my function:
handleFilesUpload (fileList) {
const uploadedFiles = this.files;
if (uploadedFiles) {
const f = uploadedFiles;
const reader = new FileReader();
reader.onload = (e) => {
const data = new Uint8Array(e.target.result);
const workbook = read(data, {
type: "array"
});
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
const json = utils.sheet_to_json(worksheet, {
header: 1,
raw: false,
});
const filteredJson = json.filter((array) => array.length > 0).splice(4, 50); // to limit the table parsed
const newJson = filteredJson.map((array) => {
// here I parse and manipulate data from arrays to return a new object
}).filter(array => !array.title.includes("undefined"));
this.excelDatas = newJson;
};
reader.readAsArrayBuffer(f);
} else {
this.excelDatas = [];
}
},