PDA

View Full Version : Updating Pivot Tables in Exel



tklemmer
4th April 2012, 14:00
Solved the problem myself... in case anybody needs to know:


QAxObject* excel = new QAxObject( "Excel.Application", 0 );

//open file
QAxObject *workbooks = excel->querySubObject( "Workbooks" );
QAxObject *workbook = workbooks->querySubObject( "Open(const QString&)", "test.xlsm" );

// write data
QAxObject * range = worksheet->querySubObject("Range(C10)");
range->setProperty("Value", QVariant(7));//DATA TO BE WRITTEN=7

// update the whole workbook
workbook->dynamicCall("RefreshAll()");

// read data
qDebug() << "Alter Wert: " << range->property("Value").toInt();

//close excel (silently)
workbook->dynamicCall("Close (Boolean)", false);
excel->dynamicCall( "Quit()");