Code:
#include <qaxobject>
#include <qaxwidget>
#include <qapplication>
int main(int argc, char *argv[])
{
const char* cp = "Range(E11)";
// because I want to read the file - not display it.
excel.setProperty("Visible", false);
QAxObject *workbooks
= excel.
querySubObject("WorkBooks");
workbooks
->dynamicCall
("Open (const QString&)",
QString("e:/tmp/test3.xls"));
QAxObject *workbook
= excel.
querySubObject("ActiveWorkBook");
// I need data from the 2nd worksheet (worksheets are numbered starting from 1)
QAxObject *worksheet
= workbook
->querySubObject
("Worksheets(int)",
2);
// Read fom the second worksheet the contents of cell E11
QAxObject *range
= worksheet
->querySubObject
(cp
);
strVal = range->property("Value").toString();
// close the excel file
excel.dynamicCall("Quit (void)");
return(0);
}