我想通过ole打开并刷新excel 2003电子表格。但是,我收到错误“添加方法Workbooks类失败”,没有进一步的信息。使用excel获取错误“工作簿类的添加方法失败”
该代码适用于单元测试,适用于3台服务器,但因Web服务器上的错误而失败。它是从本地系统帐户下运行的服务应用程序运行的。
在所有服务器(2003 sp3)上安装了相同版本的excel。所讨论的文件全部存在并且处于预期的位置。
电子表格中没有宏,但有数据库查询。电子表格可以全部打开。
调用代码
if VarIsEmpty(XLApp) then
begin
XLApp := CreateOleObject('Excel.Application');
try
XLApp.DisplayAlerts:= wdAlertsNone;
except
...
end;
XLApp.AutomationSecurity:= msoAutomationSecurityForceDisable;
end;
fullFileName:= ExpandReportFileName(partialFilename);
if not FileExists(fullFileName) then
raise Exception.Create('File not found: ' + fullFileName);
XLAPP.Workbooks.Add(fullFileName); << fail here
上还有什么我可以尝试任何想法?
刚刚尝试过,它将错误更改为“打开方法的工作簿类失败”:( – SeanX 2009-12-15 20:19:12