1

Currently, I am working on converting an Excel based calculator to a calculator that can be used on the web. This particular calculator relies on information stored in a data table with several thousands of cells.

Is there a way I can use JavaScript to get the value of a specified cell from the Excel data table? If so, how would I go about starting this process?

I have been searching for a way to do this all day, and I can't find a solution that will work for me. I tried saving the Excel table as an html file so I could work with the data that way, but the auto-generated output was over 70,000 lines and impossible to work with.

If anyone knows a way to get the value of a specified cell in Excel using JavaScript, please let me know. Any help will be greatly appreciated, and thank you in advance!

chasey
  • 13
  • 2

1 Answers1

1

You can convert your Excel table to an *.csv file!

You can read the *.csv file in Javascript with the following code (I copied it from this thread: How to read data From *.CSV file using javascript?):

$(document).ready(function() {
$.ajax({
    type: "GET",
    url: "data.txt",
    dataType: "text",
    success: function(data) {processData(data);}
 });
});
function processData(allText) {
var record_num = 5;  // or however many elements there are in each row
var allTextLines = allText.split(/\r\n|\n/);
var entries = allTextLines[0].split(',');
var lines = [];

var headings = entries.splice(0,record_num);
while (entries.length>0) {
    var tarr = [];
    for (var j=0; j<record_num; j++) {
        tarr.push(headings[j]+":"+entries.shift());
    }
    lines.push(tarr);
}
// alert(lines);

}

prttyswt
  • 72
  • 7