Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript code to open excel file and read contents

<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/jszip.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.0/xlsx.js"></script>
<script>
var ExcelToJSON = function() {

  this.parseExcel = function(file) {
    var reader = new FileReader();

    reader.onload = function(e) {
      var data = e.target.result;
      var workbook = XLSX.read(data, {
        type: 'binary'
      });

      workbook.SheetNames.forEach(function(sheetName) {
        // Here is your object
        var XL_row_object = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sheetName]);
        var json_object = JSON.stringify(XL_row_object);
        console.log(json_object);

      })

    };

    reader.onerror = function(ex) {
      console.log(ex);
    };

    reader.readAsBinaryString(file);
  };
};
</script>
Comment

PREVIOUS NEXT
Code Example
Javascript :: scroll to top 
Javascript :: adb reverse USB debugging 
Javascript :: string indexing in js 
Javascript :: add class with javascript 
Javascript :: array contains method 
Javascript :: yarn incompatible module node 
Javascript :: create new element 
Javascript :: jquery equivalent of document.getelementbyid 
Javascript :: how to convert name to initials in javascript 
Javascript :: bubble sort js 
Javascript :: javascript is null 
Javascript :: how to get the size of the window in javascript 
Javascript :: javascript fs write file with folder 
Javascript :: number to array js 
Javascript :: how to empty a filled input in cypress 
Javascript :: npm got 
Javascript :: react render after fetch 
Javascript :: react chart js 2 
Javascript :: remove undefined from object js 
Javascript :: routes in node js 
Javascript :: js class exists 
Javascript :: get option value jquery 
Javascript :: react add class to each children 
Javascript :: javascript move element to coordinates 
Javascript :: dropify use 
Javascript :: how to remove property from object javascript 
Javascript :: how to read a csv file in nodejs 
Javascript :: javascript DOM query selector 
Javascript :: getfullyear javascript 
Javascript :: vuetify autocomplete get input value 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =