Search code examples
c++excelqtactiveqt

How to append a sheet to the end of workbook in excel using ActiveQt?


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!


Solution

  • 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