Reputation: 1035
I tried the below code to open excel file using javascript. I tried in IE, Chrome, and Firefox but it's not opening the file.
<html>
<body>
<form name="form1">
<input type=button onClick="test()" value="Open File">
<br><br>
</form>
<script type="text/javascript">
function test() {
var Excel = new ActiveXObject("Excel.Application");
Excel.Visible = true;
Excel.Workbooks.Open("teste.xlsx");
}
</script>
</body>
</html>
Thanks in Advance!
Upvotes: 0
Views: 6071
Reputation: 1709
ActiveXObject is only supported by IE, other browsers don't support it.
Excel.Workbooks.Open("teste.xlsx");
There is no path specified for teste.xlsx
, provide appropriate file path. The file should be accessed by the browser in the client system, so path should be set accordingly like C:\\Temp\\teste.xlsx
(something similar with appropriate system drive).
Upvotes: 1
Reputation: 21
Try using Absolute Path of the file you are trying to open
eg:
Excel.Workbooks.Open("E:\\test.xlsx");
Upvotes: 2