0

I am interested in copying a sheet to the end of a workbook using ActiveQt I have looked at the method Copy() in the generated Documentation of QAxObject "Worksheet", which is written like:

void Copy(QVariant Before = 0, QVariant After = 0);

obviously there is no way to pass the value to the parameter After without passing something to the parameter Before.

I have been struggling to find out a way to do it but no clue was founded

I took a look at C# and VBA but they both use "missing" constant which I couldn't find in ActiveQt.

currently I am adding (or copying) before a temporary sheet, which I delete in the end.

It is not logical to have such methodes Move, Add and Copy that require parameters Before and After without a solution to use only After

so any suggestions to how to add a sheet to the end of workbook? or how to use optional parameters in ActiveQt?

Thanks in advance!

Nour
  • 41
  • 8

2 Answers2

0

QVariant has a default-constructed null value. That's what you should use for "missing" parameters, assuming that a given method accepts a missing parameter.

E.g.:

Copy({}, after); // C++11
Copy(QVariant(), after); //C++98
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
0

I have just found out the solution, the problem was in how I passed the parameters:

sheet->dynamicCall("Copy(QVariant, QVariant)", QVariant(), sheet->asVariant());

but after reading the documentation of Copy method by the hyperlink, I found out that I misread the documentaion, I should have passed it like:

sheet->dynamicCall("Copy(QVariant, QVariant)", QVariantList {QVariant(), sheet->asVariant()});
Nour
  • 41
  • 8