Results 1 to 8 of 8

Thread: Trying to export to Excel

  1. #1
    Join Date
    Oct 2009
    Location
    South Africa
    Posts
    94
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Trying to export to Excel

    I have found some code that I am playing with to learn how to export data to Excel

    Qt Code:
    1. QAxObject* excel = new QAxObject("Excel.Application", 0);
    2. QAxObject* app = excel->querySubObject("Application()");
    3. QAxObject* wbks = excel->querySubObject("Workbooks()");
    4. QAxObject* wb = wbks->querySubObject("Add()");
    5. QAxObject* ws = wb->querySubObject("Worksheets(int)", 1 );
    6.  
    7. //Show Excel
    8. app->setProperty("Visible", true );
    To copy to clipboard, switch view to plain text mode 

    However, I get the following errors:

    release/mainwindow.o:mainwindow.cpp::: error: undefined reference to `QAxObject::QAxObject(QString const&, QObject*)'
    release/mainwindow.o:mainwindow.cpp::: error: undefined reference to `QAxBase::querySubObject(char const*, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&)'
    release/mainwindow.o:mainwindow.cpp::: error: undefined reference to `QAxBase::querySubObject(char const*, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&)'
    release/mainwindow.o:mainwindow.cpp::: error: undefined reference to `QAxBase::querySubObject(char const*, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&)'
    release/mainwindow.o:mainwindow.cpp::: error: undefined reference to `QAxBase::querySubObject(char const*, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&, QVariant const&)'
    I have #include <QAxObject> at the beginning of the code.
    Can someone tell me where I am going wrong?
    Thanks.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Trying to export to Excel

    Hi, you are missing the necessary libraries during linking (QAxServer.lib and/or QAxContainer.lib). Add them to the linker command line and it should work.

    Ginsengelf

  3. The following user says thank you to Ginsengelf for this useful post:

    ShamusVW (19th April 2010)

  4. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Trying to export to Excel

    read about ActiveQt module in Assistant. Do you have your ActiveQt module already compiled?

  5. #4
    Join Date
    Oct 2009
    Location
    South Africa
    Posts
    94
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Trying to export to Excel

    I've got no idea about the ActiveQt module being compiled or not!!!?
    I installed the latest SDK, and then installed the latest Qt Creator, both .exe's. I didn't specifically compile anything.
    How do I check, and if needed, go about compiling this?

    I have added the following to my .pro file, but stil same error...

    Qt Code:
    1. LIBS += -QAxServer.lib \
    2. -QAxContainer.lib
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Oct 2009
    Location
    South Africa
    Posts
    94
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Trying to export to Excel

    Thank you. I corrected it. It is now

    Qt Code:
    1. LIBS += -lqaxserver \
    2. -lqaxcontainer
    To copy to clipboard, switch view to plain text mode 

    and it works!

  7. #6
    Join Date
    Oct 2009
    Location
    South Africa
    Posts
    94
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Trying to export to Excel

    Actually just needed

    Qt Code:
    1. 1.LIBS += -lqaxserver
    To copy to clipboard, switch view to plain text mode 

  8. #7
    Join Date
    Oct 2009
    Location
    South Africa
    Posts
    94
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Trying to export to Excel

    My apologies, it is actually the other library , i.e. qaxcontainer, not qaxserver that is needed.
    Not sure why it actually compiled using the qaxserver only, but this morning it doesn't anymore, and swopping them now lets it work again.

  9. #8
    Join Date
    Aug 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Trying to export to Excel

    i added this and its work.
    CONFIG += qaxcontainer

Similar Threads

  1. Replies: 16
    Last Post: 28th April 2020, 15:40
  2. Read excel
    By psipsi in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 18:07
  3. Replies: 3
    Last Post: 12th June 2008, 12:59
  4. ActiveQt + Excel
    By nile.one in forum Qt Programming
    Replies: 7
    Last Post: 19th October 2007, 23:58
  5. Excel using Qt
    By nmn in forum Qt Programming
    Replies: 3
    Last Post: 28th July 2007, 03:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.