Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get data from excel using 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);
      }
    },
  }
};
Comment

get data from excel using vue js

//npm install read-excel-file --save
//excel file only

<template>
	<input type="file" @change="onFileChange" />
</template>
import readXlsxFile from 'read-excel-file'
export default {
  	methods: {
        onFileChange(e) {
            var file = e.target.files ? e.target.files[0] : null;
            readXlsxFile(file).then((data) => {
            	console.log(data)
            })
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: vanilla js fade in fade out 
Javascript :: javascript array print all 
Javascript :: javascript for of loop 
Javascript :: compare date javascript 
Javascript :: nds npm 
Javascript :: javascript print to console 
Javascript :: javascript question mark 
Javascript :: Upload different files in different folders using Multer in NodeJs 
Javascript :: mongoose rename collection 
Javascript :: how to split by words and punctuation in javascript 
Javascript :: what is a for loop in javascript 
Javascript :: change image automaticly 
Javascript :: how to use cookies in react class component 
Javascript :: detect if user is online react 
Javascript :: lexical scope javascript 
Javascript :: add class to html tag javascript 
Javascript :: react: create form change state on input 
Javascript :: javascript swap array elements 
Javascript :: javascript remove index from array 
Javascript :: unzip array javascript 
Javascript :: javascript clone element 
Javascript :: await fetch parameters 
Javascript :: run file with nodemon 
Javascript :: d3js.org 
Javascript :: date javascript 
Javascript :: 100 day javascript challenge 
Javascript :: switch javascript 
Javascript :: how to export default class in javascript 
Javascript :: datatable set data of column 
Javascript :: remove object if key is duplicate javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =