Conor Curley Conor Curley - 1 year ago 100
Javascript Question

Retrieving Cell Values from an Excel Spreadsheet using JavaScript

I am looking to retrieve cells from an excel spreadsheet using JavaScript, to use the values in an HTML page. Currently, I do not know how to use SheetJS, and I am not able to use it to parse the worksheets.

What I am looking to do is: Retrieve Cell A1 -> Create a variable with the value of cell A1

Could anyone help me access the worksheet from JS and then get the value from an XLSX sheet? I have to use Excel for the purpose of this project.


Answer Source

function ReadData(cell, row) {
  var excel = new ActiveXObject("Excel.Application");
  var excel_file = excel.Workbooks.Open("C:\\RS_Data\\MyFile.xls");
  var excel_sheet = excel.Worksheets("Sheet1");
  var data = excel_sheet.Cells(cell, row).Value;
  document.getElementById('div1').innerText = data;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download