在 Delphi 7 中使用 TExcelWorkBook SaveAs 方法时出现 Ole 800A03EC 错误
我正在尝试打开 excel 2003 工作簿并将其另存为其他内容,例如 excel 95。 我使用以下代码:
XLSApp:=TExcelApplication.Create(Self);
XLSApp.Workbooks.Open(SomeFileName,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,defaultlcid);
XLSWB:=TExcelWorkbook.Create(XLSApp);
XLSWB.ConnectTo(XLSApp.Workbooks.Item[1]);
XLSWB.SaveCopyAs(ExtractFilePath(edTable.Text)+'temp.xls');
XLSWB.SaveAs(SomeOtherFileName,xlExcel7,EmptyParam,EmptyParam,False,False,xlNoChange,xlUserResolution,False,EmptyParam,EmptyParam,EmptyParam,DefaultLCID);
不幸的是,该代码在客户端计算机上给出“Ole 800A03EC”,而它在我的计算机上运行。请注意,我安装了 Office 2007,他安装了 Office 2003 SP3。
任何帮助将非常感激。
I am trying to open excel 2003 workbook and save it as something else, for example excel 95.
I use the following code:
XLSApp:=TExcelApplication.Create(Self);
XLSApp.Workbooks.Open(SomeFileName,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,defaultlcid);
XLSWB:=TExcelWorkbook.Create(XLSApp);
XLSWB.ConnectTo(XLSApp.Workbooks.Item[1]);
XLSWB.SaveCopyAs(ExtractFilePath(edTable.Text)+'temp.xls');
XLSWB.SaveAs(SomeOtherFileName,xlExcel7,EmptyParam,EmptyParam,False,False,xlNoChange,xlUserResolution,False,EmptyParam,EmptyParam,EmptyParam,DefaultLCID);
Unfortunately this code gives "Ole 800A03EC" on clients computer, while it works on mine. Note that I have Office 2007 installed, and he has Office 2003 SP3.
Any help would be very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我在自动化 Excel 时见过一次这个错误。当用户有一个单元格处于编辑模式并且您尝试自动化该实例时,就会发生这种情况。 Excel 不喜欢当您编辑单元格时某些程序在后台运行。
这就是您的客户端发生的情况(我认为):
编辑单元格(选择一个单元格并
按 F2)
如何防止这种情况发生:将 TExcelApplication 的 ConnectKind 设置为 ckNewInstance,以便您始终在单独的 Excel 实例中工作。
I have seen this error once when automating Excel. It happened when the user had a cell in editmode and you tried to automate that instance. Excel doesn't like it when you are editing a cell and some program is fiddling around in the background.
So this is what's happening at your client (I think):
editing a cell (select a cell and
press F2)
How you can prevent this: Set ConnectKind of your TExcelApplication to ckNewInstance so you'll always work in a separate Excel instance.
当一个人(比如我)做了一件愚蠢的事情,比如尝试加载到不存在的 Excel 单元格中时,也会出现 800A03EC,比如:
注意 BENE:
col
索引从 1 开始,而不是 0。800A03EC also occurs when one (like, me) does a dumb thing like trying to load into an Excel cell that doesn't exist, like:
NOTE BENE: The
col
index starts at 1, not 0.就我而言( xlExcel8 格式):
而不是:
我使用:
或
两者都工作良好...是的,我知道这是一个愚蠢的解决方案,但它有效!
In my case ( xlExcel8 format ):
Instead of:
I used:
or
Both work well... And yes, I know this is a stupid solution, but it's working!
当尝试将太多数据存储到工作表(通过 Delphi)时,我收到该错误
I'm getting that error when trying to store too much data to the WorkSheet (through Delphi)
OLE 800A03EC 通常与 Excel 文件中的无效字符有关。您使用的数据与您的客户相同吗?区域设置有区别吗?等等,这可能会有很多错误,但最有可能的是(正如快速谷歌告诉我的那样)这是一个区域设置。
OLE 800A03EC usually has to do with invalid characters in your Excel file. Are you using the same data as your client? Is there a difference in Regional Settings? Etc. etc. there could be number of errors for this, but most likely (as a quick google told me) it is a regional setting.