$ undefined after opening excel ActiveXobject

I have a local html file to do some manipulation with excel. My script tags are in my head as follows

<head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.js"></script> <script type="text/javascript"> var Excel; var ExcelSheet = new ActiveXObject("Excel.Sheet"); function openExcel(){ Excel = new ActiveXObject("Excel.Application"); Excel.Visible = true; return Excel.Workbooks.Open("C:/Users/Desktop/Temp/Input.xlsx").ActiveSheet; } function begin(){ $("div").append("zzzzzzzz"); ExcelSheet = openExcel(); $("div").append("zzzzzzzz"); } </head> 

I call the "begin" function when the button is clicked ... The first append is executed, but the second does not.

on the console it says: "$" is undefined "after execution. Before highlighting it finds JQUery I use IE9

+4
source share
1 answer

@Braiam works great

 <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.js"></script> <script type="text/javascript"> var Excel; var ExcelSheet = new ActiveXObject("Excel.Sheet"); function openExcel(){ Excel = new ActiveXObject("Excel.Application"); Excel.Visible = true; return Excel.Workbooks.Open("C:/Users/Desktop/Temp/Input.xlsx").ActiveSheet; } function begin(){ $("div").append("zzzzzzzz"); ExcelSheet = openExcel(); $("div").append("zzzzzzzz"); } </script> </head> <body> <h1>Body has loaded</h1> <div></div> <input type="button" value="Start" onclick="begin()"> </body> </html> 
+1
source

Source: https://habr.com/ru/post/1488458/


All Articles