惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

博客园 - lemontree

SQL SERVER学习计划 新的开始 C#.NET禁止一个程序启动多个实例 - lemontree - 博客园 MDI窗体,子窗体在父窗体中最大化,如果子窗体已经打开则显示,不重复打开窗体 winform里c#验证用户正确后 怎么打开新窗口时关闭登陆窗口 Are You Going To Scarborough Fair中文歌词 安装VS2005 SP1失败 (转载)浅析HTTP协议 (转载)你是合格的程序员吗?—合格程序员应该具备的12种能力 夯实基础,从HTML开始 SQLserver2000〔Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server不存在或访问被拒绝 压缩数据库日志文件 RDLC报表(一) [转载]OWC做电子表格和图表的试验 .net 2.0 Configuration Error 浅谈ASP.NET的内部机制(一) seo专题之开篇有益 OWC生成Excel的效能优化 妇女节各人的不同回复
引用Microsoft.Office.Interop.Excel出现的问题
lemontree · 2009-03-10 · via 博客园 - lemontree

转自:http://www.hccar.com/Content,2008,6,11,75.aspx,作者:方继祥

操作背景:asp.net操作Excel

出现问题:在本地添加引用(com):Microsoft Office 11.0 Object Library,并写好程序调试正常,部署到服务器时,出现异常 Excel.Application不是对象.

初步诊断:服务器没有安装Excel组件

第一步尝试解决:对服务器安装Excel等Office组件,进一步测试程序:失败!

第二步尝试解决:将Excel.exe生成Interop.Excel.dll,然后用sdk引用该Dll,编译成功,测试程序:成功!

原因:本地引用的com不会在程序的bin目录生成dll文件,而程序是根据路径在寻找dll的.部署到服务器上时,假如Excel等dll与本地路径不一致,将会抛出异常,定义的Excel对象肯定是不存在的.

具体方法:

1、如何生成Interop.Excel.dll?

     进入你的visual studio的sdk下的bin目录,找到TlbImp.exe文件,如果没有,请用光盘安装此文件,详细说明请参照MSDN。
     命令行(cmd)进入bin目录,运行TlbImp /out:Interop.Excel.dll Office安装目录+Excel.exe

     此时很可能会报错:TlbImp   error:   Unable   to   locate   input   type   library:   'c:\program files\mcrosoft offi  
  ce\office\EXCEL.EXE'
     此问题很有可能是TlbImp的bug,不支持空格式的路径;(具体原因不明)不要紧,将Excel.exe拷贝入bin目录,直接运行TlbImp /out:Interop.Excel.dll Excel.exe,提示“Type library imported to Interop.Excel.dll路径”

     在bin目录下找到Interop.Excel.dll文件。在你的visual studio里将其引用即可。

2、如果是excel2000或excel2002怎么办?

  如果是Excel2000,则将Excel.exe改成Excel9.olb
  Excel2002同2003

3、各种版本的引用组件参数如下:

文件/版本 Interop.Excel.dll Interop.Office.dll Interop.VBIDE.dll 添加引用\COM组件
2000 V1.3.0.0 V2.1.0.0 V5.3.0.0 Microsoft Excel 9.0 Object Library(EXCEL9.OLB)
2002(XP) V1.4.0.0 V2.2.0.0 V5.3.0.0 Microsoft Excel 10.0 Object Library(Excel.EXE文件)
2003 V1.5.0.0 V2.3.0.0 V5.3.0.0 Microsoft Excel 11.0 Object Library(Excel.EXE文件)