To create a new QT GUI project, tick ACTIVEQT Container in the selection options.
#include <qaxobject.h>
Qaxobject *obj = new Qaxobject ("Excel.Application");
Obj->setproperty ("Visible", true);
Obj->setproperty ("Caption", "Hello World");
Qaxobject *workbooks = Obj->querysubobject ("WorkBooks");
Open an existing Excel file
Qaxobject *workbook = Workbooks->querysubobject ("Open (QString)", "D:\\qtdemo\\opexcel\\debug\\1.xls");
Workbooks->dynamiccall ("Add");
Qaxobject *workbook = Workbooks->querysubobject ("Item (const int)", 1);
Qaxobject *sheets = workbook->querysubobject ("sheets");
Qaxobject *sheet = Sheets->querysubobject ("Item (int)", 1);
Qaxobject *range = Sheet->querysubobject ("Range (const qvariant&)", Qvariant (QString ("a1:a1"));
Range->dynamiccall ("Clear ()");
Range->dynamiccall ("SetValue (const qvariant&)", Qvariant (5));
Obj->dynamiccall ("setscreenupdating (BOOL)", true);
Insert a chart in Excel
Qaxobject *excel = new Qaxobject ("Excel.Application", 0);
Excel->setproperty ("SheetsInNewWorkbook", 1);
Excel->setproperty ("Visible", true);
Qaxobject *workbooks = Excel->querysubobject ("workbooks");
Qaxobject *workbook = Workbooks->querysubobject ("Add");
Qaxobject *worksheet = Workbook->querysubobject ("Worksheets (int)", 1);
Worksheet->setproperty ("Name", "Dati applicazione");
Qaxobject *cell = Worksheet->querysubobject ("Cells (Int,int)", 1, 1);
Cell->dynamiccall ("SetValue (String)", "Serie");
Cell = Worksheet->querysubobject ("Cells (Int,int)", 1, 2);
Cell->dynamiccall ("SetValue (String)", "Dati");
for (int i = 2; i < i++) {
Cell = Worksheet->querysubobject ("Cells (Int,int)", I, 1);
Cell->dynamiccall ("SetValue (int)", i-1);
Cell = Worksheet->querysubobject ("Cells (Int,int)", I, 2);
Cell->dynamiccall ("SetValue (Double)", Qrand ());
}
Qaxobject *charts = workbook->querysubobject ("charts");
Qaxobject *chart = Charts->querysubobject ("Add");
Chart->setproperty ("Name", "Report Grafico dei dati");
Chart->setproperty ("ChartType", 73);
Qaxobject * serie = chart->querysubobject ("SeriesCollection (int)", 1);
Qaxobject * xvalues = Worksheet->querysubobject ("Range (A2:A9)");
Qaxobject * yvalues = Worksheet->querysubobject ("Range (B2:B9)");
Serie->setproperty ("XValues", Xvalues->asvariant ());
Serie->setproperty ("Values", Yvalues->asvariant ());
http://blog.csdn.net/henreash/article/details/7397774
QT Operations Excel (using OLE with Qaxobject, if Excel is installed locally)