我正在尝试通过 ole 打开和刷新 excel 2003 电子表格。但是,我收到错误“工作簿类的添加方法失败”,没有更多信息。
该代码在单元测试中工作,在 3 个服务器上工作,但在我们的 Web 服务器上失败并出现错误。它是从在本地系统帐户下运行的服务应用程序运行的。
所有服务器上都安装了相同版本的 excel (2003 sp3)。有问题的文件都存在并且位于预期的位置。
电子表格中没有宏,但有数据库查询。电子表格都可以打开。
调用代码是
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
关于我还能尝试什么的任何想法?