PDA

View Full Version : Trying to export to Excel



ShamusVW
19th April 2010, 15:10
I have found some code that I am playing with to learn how to export data to Excel


QAxObject* excel = new QAxObject("Excel.Application", 0);
QAxObject* app = excel->querySubObject("Application()");
QAxObject* wbks = excel->querySubObject("Workbooks()");
QAxObject* wb = wbks->querySubObject("Add()");
QAxObject* ws = wb->querySubObject("Worksheets(int)", 1 );

//Show Excel
app->setProperty("Visible", true );

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.

Ginsengelf
19th April 2010, 15:32
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

faldzip
19th April 2010, 16:04
read about ActiveQt module in Assistant. Do you have your ActiveQt module already compiled?

ShamusVW
19th April 2010, 17:56
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...


LIBS += -QAxServer.lib \
-QAxContainer.lib

ShamusVW
19th April 2010, 18:00
Thank you. I corrected it. It is now


LIBS += -lqaxserver \
-lqaxcontainer

and it works!

ShamusVW
19th April 2010, 18:02
Actually just needed


1.LIBS += -lqaxserver

ShamusVW
20th April 2010, 07:43
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.

szworker
4th August 2010, 08:07
i added this and its work.
CONFIG += qaxcontainer