如何从Excel获取单元格超链接地址?

时间:2013-04-24 13:01:12

标签: excel qt activex qt5 qaxobject

要从单元格中读取文本,请使用:

QAxObject *e = new QAxObject("Excel.Application");
QAxObject *wbooks = e->querySubObject("Workbooks");
QAxObject *wbook = wbooks->querySubObject("Open(const QString&)", "somefile.xls");
QAxObject *s = wbook->querySubObject("Worksheets(int)", 1);
QVariant v = s->querySubObject("Cells(int,int)", 2, 2)->property("Value");
// v = "sometext"

但是如何从单元格读取超链接地址?

Qt 5.0.1 Windows 7

1 个答案:

答案 0 :(得分:0)

尝试:

QAxObject *e = new QAxObject("Excel.Application");
QAxObject *wbooks = e->querySubObject("Workbooks");
QAxObject *wbook = wbooks->querySubObject("Open(const QString&)", "somefile.xls");
QAxObject *s = wbook->querySubObject("Worksheets(int)", 1);
QVariant v = s->querySubObject("Cells(int,int)", 2, 2)->querySubObject("Hyperlinks(int)", 1)->property("Address");