Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
82
rated 0 times [  84] [ 2]  / answers: 1 / hits: 15933  / 5 Years ago, tue, august 27, 2019, 12:00:00

I am dynamically generating excel template file using vue-json-excel for the user. After user filling data in the template file i want take it as a input and convert all data in JSON formate and send it to the server side but not getting how to do .



<template>
<div id=app>
<md-field @change=previewFiles>
<label>upload excel file</label>
<md-file v-model=metaDataFile @change=previewFiles />
</md-field>
</div>
</template>

<script>
export default {
components: {
loginComponent,
uploadComponent
},
data() {
return {
metaDataFile: null
}
},
methods:{
previewFiles(event) {
console.log(event.target.files);
console.log(this.metaDataFile);
}
}
}

</script>

More From » json

 Answers
25

this worked for me


 previewFiles(e) {
var files = e.target.files, f = files[0];
var reader = new FileReader();
reader.onload = function(e) {
var data = new Uint8Array(e.target.result);
var workbook = XLSX.read(data, {type: 'array'});
let sheetName = workbook.SheetNames[0]
/* DO SOMETHING WITH workbook HERE */
console.log(workbook);
let worksheet = workbook.Sheets[sheetName];
console.log(XLSX.utils.sheet_to_json(worksheet));
};
reader.readAsArrayBuffer(f);
}

[#51727] Monday, August 19, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kylanalis

Total Points: 438
Total Questions: 85
Total Answers: 102

Location: Barbados
Member since Sun, Nov 27, 2022
1 Year ago
kylanalis questions
Sat, Oct 2, 21, 00:00, 3 Years ago
Tue, Oct 13, 20, 00:00, 4 Years ago
Thu, Feb 13, 20, 00:00, 4 Years ago
Tue, Jan 7, 20, 00:00, 4 Years ago
;