How to Open Excel File Using JavaScript Code Without Using Activex Control

How to open excel file using JavaScript code without using ActiveX control?

It's possible to open .xlsx files with Javascript because they are ZIP packages. This has been experimented with XForms: http://www.w3.org/community/xformsusers/2012/12/19/editing-zip-with-xforms/

Javascript Excel OpenFile

Firstly, try moving your script to the bottom of the body. You should also set your Excel variable to be visible. And there's a typo with the line Excel.Workbook.Open("teste.xlsx"); (should be Workbooks). The following is working for me in IE. I don't think it will work in other browsers:

<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>

Open Excel file url in excel (from source, not downloaded copy)

No it is not possible for security reasons. All newer browsers (and I guess even the newer implementations of IE), don't allow file access to the local system. Internet Explorer is the only browser that supports opening files from locations, that are seen and treated as local ones.

You can open files from a Webdav Server, which is probably, why you can access files from your SharePoint, so you could try mapping that provider of your network drive as a Webdav Server.

Source: https://www.codeproject.com/Questions/1180249/Open-edit-save-excel-sheet-from-browser-using-java AND
Is there an Application URL Protocol for MS Word?

How to manipulate Excel file on the client side

As a dirty workaround, how about generating a .bat file with the appropriate DOS copy commands? If your user is happy to download and execute the file, it might do the job!

I've done something similar with a web app that generates commands for a local macro program.

For example:
You might save the following to copy the file to the correct directory

copy c:\\path\to\download\file.xls n:\\path\to\networked\destination

or you could make use of built in windows commands to handle the file download

curl.exe -0 c:\\path\to\download\file.xls https://domain_with_file.com/file.xls

This isn't an ideal way of doing things though, and it looks as if any batch files downloaded might be flagged up as potential virus threats.



Related Topics



Leave a reply



Submit