As mentioned in @Alex K, this will only work in IE. Here a solution is possible:
Put all your Excel files in the same folder. For example: C:\sheets\ (Edit: I think this is the easiest solution, since I do not know how to get the full and real file path through javascript)
Now change the code to something in these lines:
<input type="file" id='excelFile' /> <button id='loadExcel'>Load Excel File</button> <script type="text/javascript"> var EXCELDIR = "C:\\sheets\\"; var loadExcel = document.getElementById('loadExcel'); loadExcel.onclick = function() { var filepath = EXCELDIR + document.getElementById('excelFile').value.split('\\')[2]; readdata(1,2, filepath); } function readdata(x,y,filepath) { try { var excel = new ActiveXObject("Excel.Application"); excel.Visible = false; var excel_file = excel.Workbooks.Open(filepath); alert(excel_file.worksheets.count); var excel_sheet = excel_file.Worksheets("Sheet1"); var data = excel_sheet.Cells(x, y).Value; </script>
Disclaimer: I have not tested the code since I am on a mac, hope this works.
source share