I have a Qt application working with Excel, and I want to add a worksheet to a document. The simpliest solution is just call
QAxObject *sheets = workbook->querySubObject("Worksheets");
sheets->dynamicCall("Add()");
But this way you'll add a sheet BEFORE the last existing sheet, but I want to place it AFTER last sheet. Generated documentation will say you:
IDispatch* Add (QVariant Before, QVariant After, QVariant Count, QVariant Type) [slot]
Connect a signal to this slot:
QObject::connect(sender, SIGNAL(someSignal(QVariant, QVariant, QVariant, QVariant)), object, SLOT(Add(QVariant, QVariant, QVariant, QVariant)));
Or call the function directly:
QVariantList params = ...
QAxObject * result = object->querySubObject("Add(QVariant, QVariant, QVariant, QVariant)", params);
But how should params be like? As I can see, "after" is second param, however I don't need "before" at all. What should I specify as params?
You have to specify the last and the new sheet, otherwise if BEFORE and AFTER were both omitted, the new sheet will be inserted before the active sheet by default.
You can do something like this to insert after the last sheet: