Obtenha dados do CSV usando o VUE JS
//<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>
//excel/csv
<template>
<input type="file" @change="onFileChange" />
</template>
export default {
methods: {
onFileChange(event) {
this.file = event.target.files ? event.target.files[0] : null;
if (this.file) {
const reader = new FileReader();
reader.onload = (e) => {
/* Parse data */
const bstr = e.target.result;
const wb = XLSX.read(bstr, { type: 'binary' , cellDates: true, dateNF: 'yyyy/mm/dd;@'});
/* Get first worksheet */
const wsname = wb.SheetNames[0];
const ws = wb.Sheets[wsname];
/* Convert array of arrays */
const data = XLSX.utils.sheet_to_json(ws, { header: 1 });
console.log(data)
}
reader.readAsBinaryString(this.file);
}
},
}
};
iF n OnLy iF