Re: How can I create an XlfOper with a multi dimensional array ?

Posted by Xiaofeng Zheng on
URL: http://quantlib.414.s1.nabble.com/Re-How-can-I-create-an-XlfOper-with-a-multi-dimensional-array-tp10756.html

Adjriou,

I suppose you meant 2-dimensional array. I found a way after reading
the xlw code, not necessarily the best way.

Cheers,
Xiaofeng

        Integer numQuotes = rateVector.size();
        XlfOper *output = new XlfOper[ 2 * numQuotes ];

        // This is the way to output 2-dim data to XL.
        for (Integer j = 0; j < numQuotes; ++j) {
            boost::shared_ptr<RateHelper> node = rateVector[j];
            Date tenor = node->latestDate();

            output[j*2 + 0] = XlfOper(
                DateFormatter::toString(
                tenor, DateFormatter::Short ));

            output[j*2 + 1] = XlfOper(
                termStructure->discount(tenor) );
        }

        return XlfOper(numQuotes, 2, output );