Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Array in Worksheet Functions STDEV (Excel in C++) (http://www.go4expert.com/forums/array-worksheet-functions-stdev-excel-t20975/)

CPPLearner 13Feb2010 03:21

Array in Worksheet Functions STDEV (Excel in C++)
I have been pretty successful in understanding the implementation of drawing charts in and exporting data to excel. Now I am trying to implement Excel Worksheet functions in C++. Here is the working structure of it:

double wf = xl->Application->WorksheetFunction->STDEV(1,2,3,4,5);

However, I have not been successful in passing an array or vector of doubles to STDEV. E.g. If I have an array: arr[5] = {1,2,3,4,5};
How do I implement:

double wf2 = xl->Application->WorksheetFunction->STDEV(arr);

The kind of errors that I am getting currently relates to passing of the data type into STDEV. Is there a way to convert my arr to const _variant_t type? As this is the type which is being accepted as argument to function STDEV.

Any leads?

Gene Poole 13Feb2010 03:35

Re: Array in Worksheet Functions STDEV (Excel in C++)
I don't know anything about excel automation, but I would think that you need to pass a "SAFEARRAY".

Look for help on msdn. Here's one with an example:


All times are GMT +5.5. The time now is 12:22.