The associated COM server does not support ActiveX Document embedding

winfrom 通过dsoframer实现读取excel文件报错:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80041103): The associated COM server does not support ActiveX Document embedding.

   at DSOFramer._FramerControl.Open(Object Document, Object ReadOnly, Object ProgId, Object WebUsername, Object WebPassword)

   --- End of inner exception stack trace ---

解决方法:

Open时把第三个progID加上就可以,

2.  HRESULT Open([in] VARIANT Document, [in, optional] VARIANT ReadOnly, 
[in, optional] VARIANT ProgId, [in, optional] VARIANT WebUsername, [in, optional] VARIANT WebPassword)
    打开文档,可以是本地文件或者是服务器文件
参数:
Document  文档路径
ReadOnly  是否已只读模式打开
ProgId    OLE类型
WebUsername  用户名(访问网络的文件时候,有可能需要)
WebPassword  密码
例子:

axFramerControl1.Open(sPath, true, "Excel.Sheet", "", "");//
DsoFramer1.Open "C:\TestBook.xls"
DsoFramer1.Open "C:\Plain.txt", , "Word.Document"  //用Word来打开c:\plain.txt文件
DsoFramer1.Open "https://secureserver/test/mytest.asp?id=123", True, "Excel.Sheet", "MyUserAccount", "MyPassword"

3.HRESULT Save([in, optional] VARIANT SaveAsDocument, [in, optional] VARIANT OverwriteExisting, 
                [in, optional] VARIANT WebUsername, [in, optional] VARIANT WebPassword);
保存文件在本地
DsoFramer1.Save "c:\1.doc"

转载于:https://www.cnblogs.com/zhycyq/p/3322237.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值