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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Xiaofeng Zheng
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 );