简体   繁体   中英

How to enable ActiveX controls not marked as safe using javascript code for IE, while reading XLS/XLSX local files

without enabling manually Internet Explorer -> Internet Control Panel -> Security Page -> Internet Zone -> "Initialize and script ActiveX controls not marked as safe" must be “Enabled” has to be done using javascript code.

 var ex; try { ex = new ActiveXObject("Excel.Application"); } catch (e) { alert('Your browser does not support the Activex object.\\nPlease switch to Internet Explorer.'); } var ef = ex.Workbooks.Open(oFileIn.value); var es = ex.Worksheets(so); var rs = parseInt(ho, 10); var cs = parseInt(co, 10); var ce = cs + parseInt(hco, 10) - 1; var re = rs + parseInt(ro, 10); 

If I understand your question, you want to script an ActiveX not marked as safe. You can't. This is exactly the purpose of this setting, to block execution of scripts not explicitly allowed by the user.

As a solution, you could run a powershell script in the client machine to mark the desired ActiveX as safe.

https://blogs.technet.microsoft.com/fdcc/2011/11/03/enabling-initialize-and-script-activex-controls-not-marked-as-safe-in-any-zone-can-get-you-hurt-bad/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM