Search code examples
excelqtactivexqt5qaxobject

How get cell hyperlink address from Excel?


To read text from cell I use this:

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"

But how read hyperlink address from cell?

Qt 5.0.1 Windows 7


Solution

  • Try:

    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");