博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(tips,javascript,office)客户端操作excel文档的注意事项
阅读量:4575 次
发布时间:2019-06-08

本文共 1916 字,大约阅读时间需要 6 分钟。

最近项目需要使用javascript将客户端上面的excel文档读取,于是继续网上搜索代码看到孟子大哥给别人的一段回复中给了一个new ActiveXobject(Application.Excel)的代码,我在页面中使用后出现了automation服务器不能创建对象的错误,查找了下大多数答案都是说没权限,改ie设置,但是具体的如何改正却是没说清楚,咱们中国论坛的这样的风气太害人了(回答问题从来很多人都不说清楚,简单的说下就完了),所以最后还是在国外某个论坛上面查到了解决方案:

======================================================
ref question:
The following javascript has been working just fine for the last 5 months.
Now, for no apparent reason, the following error occurs when the script is
run.
"Automation server can't create object"
The script is below. Please note that the parameter passed to the function
is a valid path/filename.
I tried setting all browser security settings to "low", but this did not
resolve the problem.
Any suggestions are greatly appreciated.
-----------------------------------
<script language="JavaScript">
function startWord(strFile)
{
var myApp = new ActiveXObject("Word.Application");
if (myApp != null)
{
myApp.Visible = true;
myApp.Documents.Open(strFile);
}
}
</script>
ref solution:
 1.Undo what you just did, first of all. Then
you need to tweak the properties of the level that the site is in. Tools ?
Internet Options… ? choose tab Security ? click button Custom level ? scroll
to 'Run ActiveX controls and plug-ins' ? select ‘prompt’ or ‘enable’.
Presumably something 's changed there, probably we 'll never know how.
 2 That particular setting didn't fixed the problem. However, I decided to try
some of the others in that section. Turns out the problem has been resolved
by enabling the following setting "Initialize and script ActiveX control not
marked as safe.
======================================================
网上很多人说是用开始/运行/regsvr32 scrruning.dll来解决,可是很多时候使用这个并不一定能解决问题。我觉得很多情况下应该属于IE安全设置的问题,和运行不运行那个注册dll没关系。现在上面的论述已经可以说明不仅仅需要更改ie设置安全标签里面internet站点里面自定义站点,将运行未签名的activex控件以及是否初始化activex脚本并运行沟选上才能避免出现automation服务器不能创建对象的对话框。

转载于:https://www.cnblogs.com/ocean2000/archive/2007/10/31/944241.html

你可能感兴趣的文章
GPS.NET 和 GeoFramework开源了
查看>>
汇编:采用址表的方法编写程序实现C程序的switch功能
查看>>
AtiveMQ初次连接的 http error:503 连接错误 Prolem accessing /.Reason : Service Unavailable...
查看>>
OFO和摩拜共享单车
查看>>
Linux软件安装管理之1——rpm命令管理
查看>>
关于 Failed to establish a new connection: [Errno 11004] getaddrinfo failed',))的问题
查看>>
JavaScript中严格判断NaN
查看>>
json_encode不自动转义斜杠“/”的方法
查看>>
CentOS 7安装PHP依赖管理Composer以及指定PHP版本使用Composer
查看>>
循序渐进大型网站架构
查看>>
Nodejs+Express 搭建 web应用
查看>>
2013春节出游兴“专机游”
查看>>
mysql 创建用户名及密码
查看>>
五 搭建kafka集群
查看>>
Linux 内核即插即用规范
查看>>
【规范】javascript 变量命名规则
查看>>
数据适配 DataAdapter对象
查看>>
有序列表ol和定义列表dl,dt,dd
查看>>
联想小新Air 15 安装黑苹果macOS High Sierra 10.13.6过程
查看>>
公共POI导出Excel方法–java
查看>>