-1

I have an URL, say

abc.com/download?fileid=123&entity_id=456&sid=101

which downloads an excel file when I click the link. Instead of downloading it, I want to read its contents with HTML & javascript in order to process the information automatically.

Is there a way to do that? I am not familiar with web programming therefore I am not sure how to proceed. I have tried the following, but nothing happened.

var excel = new ActiveXObject("Excel.Application");
var excel_file = excel.Workbooks.Open("url here");
var excel_sheet = excel_file.Worksheets("Sheet1");
var data = excel_sheet.Cells(1,2).Value;
alert(data);

edit: my question is different from the linked one as I am also trying to figure out how to get the initial raw data which will be parsed once I get it into a variable (however simple the answer might be, I could not find it anywhere else and this is my first practice with web so I couldn't find a way around).

Can the code above access the file in the URL? I do not know how to test it and writing alert(data) returns no result. How do I know I have some data to work with, before I start parsing?

edit2: following returns something when urlString="www.google.com", but it do not return anything with the URL I have, probably because it is a download link.

$.get(urlString, function(data, status){
alert("Data: " + data + "\nStatus: " + status);});
ozgeneral
  • 6,079
  • 2
  • 30
  • 45
  • Possible duplicate of [How to parse Excel file in Javascript/HTML5](http://stackoverflow.com/questions/8238407/how-to-parse-excel-file-in-javascript-html5) – Brian Peacock Jan 27 '16 at 10:26

1 Answers1

1

Microsoft Exel files (xls|xlsx) are proprietary format. You need to do a lot of work in order to transform them into a form that can be manipulated with JavaScript and injected into a html document.

Luckily some geeky boffins have done all the hard work already, in the form of the JS-XLS and JS-XLSX JavaScript libraries.

See this page @ CodeTheory.com for a brief breakdown of their capabilities.

Brian Peacock
  • 1,801
  • 16
  • 24
  • That seems good, but as I said I am a beginner in web programming and I cannot figure out how to get the initial raw file to work with. I mean, I understand how to use those functions to parse the file, but what code do I use to get the data that will be parsed in the first place. – ozgeneral Jan 27 '16 at 14:27
  • @OE1 For that you're probably going to need to make an HTTP Request. See [MDN AJAX Getting Started](https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started) – Brian Peacock Jan 28 '16 at 12:00