查看完整版本: [-- QAxbase 操作Excel时异常捕获 --]

QTCN开发网 -> 其它技术开发讨论区 -> QAxbase 操作Excel时异常捕获 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

no_more 2022-01-07 14:31

QAxbase 操作Excel时异常捕获

今天我在使用QAxbase操作Excel时,当数据部分填充完毕,进行保存时,保存失败(原因:当前Excel被占用,我保存时用的同名文件),此时控制台打印如下

[2022-01-05 14:50:41] warning [21756] : QAxBase: Error calling IDispatch member SaveAs: Exception thrown by server
[2022-01-05 14:50:41] warning [21756] :              Code       : 1004
[2022-01-05 14:50:41] warning [21756] :              Source     : Microsoft Excel
[2022-01-05 14:50:41] warning [21756] :              Description: ?????????????.xlsx??
[2022-01-05 14:50:42] warning [21756] :              Help       : xlmain11.chm
[2022-01-05 14:50:42] warning [21756] :          Connect to the exception(int,QString,QString,QString) signal to catch this exception

我在使用代码connect(
            d->m_excel,
            SIGNAL(exception(int, const QString &, const QString &, const QString &)),
            this,
            SLOT(onAxWidgetException(int, const QString &, const QString &, const QString &)));连接信号槽之后,再次重复上述操作,打印的错误依然不变。
最后我打开源码看到,源码中QAxbase定义信号时有一个宏qdoc的判断:

#ifdef qdoc
Q_SIGNALS:
    void signal(const QString&,int,void*);
    void propertyChanged(const QString&);
    void exception(int,const QString&,const QString&,const QString&);
#endif

不知道大佬们有没有什么解决的办法,可以让我捕捉到异常信息?  感谢

no_more 2022-01-07 14:36
有没有大佬帮小弟看一看呀


查看完整版本: [-- QAxbase 操作Excel时异常捕获 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled