我希望使用QAxObject来处理Excel文件。
我希望在某种程度上实现初始化,类似于以下代码:
QAxObject* excel;//excel pointer
void initExcel(){
try
{
//if there excel process already running try to use it
}
//catch if it's not running
catch()
{
try
{
excel = new QAxObject("Excel.Application");
}
catch
{
//meassge if excel not exist/can't start
}
}
}如何用QAxObject捕获/抛出错误?我试着用谷歌搜索,但没有找到任何exapmlpe
发布于 2013-10-18 12:31:40
要知道是否加载了ActiveX控件,您应该使用setControl方法的结果。若要捕获ActiveX控件的异常,应连接到异常信号。
bool controlLoaded = axWidget->setControl("Word.Document");
if (!controlLoaded)
{
// Message about control didn't load
}
else
{
// Control loaded OK; connecting to catch exceptions from control
connect(
axWidget,
SIGNAL(exception(int, const QString &, const QString &, const QString &)),
this,
SLOT(onAxWidgetException(int, const QString &, const QString &, const QString &)));
}https://stackoverflow.com/questions/19442177
复制相似问题