Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get data from csv 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

PREVIOUS NEXT
Code Example
Javascript :: /on in jquery 
Javascript :: html javascript find data attribute 
Javascript :: jquery reset form fields 
Javascript :: javascript string includes 
Javascript :: jquery trigger event when scroll to div 
Javascript :: how to disable react in jsx scope eslint 
Javascript :: find string in array javascript 
Javascript :: read csv file in javascript 
Javascript :: get status bar height react native 
Javascript :: toggle hidden attribute javascript 
Javascript :: remove all white space from text javascript 
Javascript :: javascript sort by big amount to small desc 
Javascript :: javascript seconds to date 
Javascript :: jquery replace text in button 
Javascript :: javascript filter unique 
Javascript :: javascript key pressed enter 
Javascript :: window.onload in javascript 
Javascript :: update angular materia; 
Javascript :: js api call 
Javascript :: tab active check 
Javascript :: angular goto top of page 
Javascript :: get child routes using parent in angular 
Javascript :: content editable vuejs 
Javascript :: dom click is not a function 
Javascript :: find the max length of string elements in an array 
Javascript :: javascript get url parameters 
Javascript :: convert hex code to rgb javascript 
Javascript :: new jsonobject java 
Javascript :: javascript dice throw 
Javascript :: fluttter http get 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =