Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

read xlsx file in angular 5

//import it

    import * as XLSX from 'ts-xlsx';

//inside export class

arrayBuffer:any;
file:File;
incomingfile(event) 
  {
  this.file= event.target.files[0]; 
  }

 Upload() {
      let fileReader = new FileReader();
        fileReader.onload = (e) => {
            this.arrayBuffer = fileReader.result;
            var data = new Uint8Array(this.arrayBuffer);
            var arr = new Array();
            for(var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
            var bstr = arr.join("");
            var workbook = XLSX.read(bstr, {type:"binary"});
            var first_sheet_name = workbook.SheetNames[0];
            var worksheet = workbook.Sheets[first_sheet_name];
            console.log(XLSX.utils.sheet_to_json(worksheet,{raw:true}));
        }
        fileReader.readAsArrayBuffer(this.file);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Use Destructuring Assignment with the Rest Operator to Reassign Array Elements 
Javascript :: react antd form disable submit button 
Javascript :: .textcontent in javascript 
Javascript :: Javascript removing duplicates in array 
Javascript :: react native header 
Javascript :: js substring first 4 numbwe 
Javascript :: timestamp convert moment vue 
Javascript :: divisible by 3 javascript 
Javascript :: javascript capitalize 
Javascript :: continuous scrolling js 
Javascript :: convert json to dataframe 
Javascript :: javascript multidimensional array foreach 
Javascript :: js capitalize first letter of each word 
Javascript :: jquery list all event listeners 
Javascript :: check user by id discord js 
Javascript :: javascript merge array 
Javascript :: pretty alerts js 
Javascript :: input focus in jquery 
Javascript :: loop through json array and get key name 
Javascript :: react router get data from url 
Javascript :: how to change background color on scroll 
Javascript :: increased the value of a counter when a button is clicked in js 
Javascript :: preview upload image jquery 
Javascript :: react bootstrap form select 
Javascript :: javascript random number up to including 2 
Javascript :: cookie clicker hack extension 
Javascript :: dm command discord.js 
Javascript :: convert associative array to json javascript 
Javascript :: how to find all elements starting with class jquery 
Javascript :: mongoose pagination with total count 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =