Click here to Skip to main content
15,921,548 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralIs this Possible Pin
ThatsAlok11-May-05 21:07
ThatsAlok11-May-05 21:07 
GeneralRe: Is this Possible Pin
Vi212-May-05 21:13
Vi212-May-05 21:13 
GeneralRe: Is this Possible Pin
ThatsAlok12-May-05 21:50
ThatsAlok12-May-05 21:50 
GeneralRe: Is this Possible Pin
Vi212-May-05 22:04
Vi212-May-05 22:04 
GeneralATL Component not working properly in windows 98 Pin
naveen.V8-May-05 22:55
naveen.V8-May-05 22:55 
GeneralMTS packages Pin
Pavneet Singh7-May-05 8:19
Pavneet Singh7-May-05 8:19 
GeneralEmbed Exectuable Pin
zx2c46-May-05 15:16
zx2c46-May-05 15:16 
GeneralOutput Atl Variant Function under Excel Pin
Member 18924296-May-05 4:51
Member 18924296-May-05 4:51 
I programmed my Function like one in the book from Duffie: Financial Instrument Pricing using c++
. The Problem is That the output is a row vektor.
Does anyone have an Idea How to make the Output a Column Range and not a row Vektor under Excel ?


Here s the code:

STDMETHODIMP CMyExcelFunctions::MyArrayFunction(VARIANT* range1, VARIANT* range2, VARIANT* result)
{

// Convert input to vector
Vector<double> v1=COMUtils::ExcelRangeToVector(range1);
Vector<double> v2=COMUtils::ExcelRangeToVector(range2);

// Determine the minimum size of both input arrays
size_t size;
if (v1.Size()<v2.size()) size="v1.Size();
size=v2.Size();

//" add="" both="" arrays="" (v1+v2="" does="" not="" take="" different="" vector="" sizes="" in="" account)
vector<double=""> vr(size);
for (int i=vr.MinIndex(); i<=vr.MaxIndex(); i++)
{
vr=v1+v2;
}

// Put result in safe array
CComSafeArray<double> res;
res.Create(size);

LONG j;
for (i=vr.MinIndex(), j=0; i<=vr.MaxIndex(); i++, j++)
{
res.SetAt(j, vr);
}

// Put safe array in variant
CComVariant v(res);

// Put resulting variant in result
v.Detach(result);

return S_OK;
}





Vector<double> COMUtils::ExcelRangeToVector(VARIANT* range)
{
// Check if a range object was passed
if (range->vt!=VT_DISPATCH)
{
// No range passed so just return the double value in a vector
Vector<double> v(1);
v[v.MinIndex()]=range->dblVal;
return v;
}

// Retrieve the Excel range object from the variant and convert it to a Vector<double>
Excel::RangePtr pRange=range->pdispVal;
return COMUtils::ExcelRangeToVector(pRange);
}

// Convert an Excel range to our vector template class
Vector<double> COMUtils::ExcelRangeToVector(Excel::RangePtr pRange)
{
// Get the number of rows and columns in the range
int columns=pRange->Columns->Count;
int rows=pRange->Rows->Count;

// Create the vector with the correct size
Vector<double> v(columns*rows);

// Iterate the rows and columns
int index=v.MinIndex();
for (int r=1; r<=rows; r++)
{
for (int c=1; c<=columns; c++)
{
// Add each element in the range to our vector
v[index++]=(((Excel::RangePtr)pRange->Item[r][c])->Value).dblVal;
}
}



// Return the vector
return v;
}


Thanks
GeneralImplement WTL application as a static library Pin
marcpolo3-May-05 22:50
marcpolo3-May-05 22:50 
GeneralUpdateAllViews Pin
act_x3-May-05 11:22
act_x3-May-05 11:22 
GeneralRe: UpdateAllViews Pin
Michael Dunn4-May-05 16:40
sitebuilderMichael Dunn4-May-05 16:40 
Generaloops Pin
knapak29-Apr-05 9:28
knapak29-Apr-05 9:28 
GeneralRe: oops Pin
toxcct18-May-05 3:08
toxcct18-May-05 3:08 
QuestionPointers to vectors? Pin
knapak29-Apr-05 9:25
knapak29-Apr-05 9:25 
AnswerRe: Pointers to vectors? Pin
Stuart Dootson29-Apr-05 9:52
professionalStuart Dootson29-Apr-05 9:52 
GeneralRe: Pointers to vectors? Pin
knapak29-Apr-05 10:04
knapak29-Apr-05 10:04 
GeneralRe: Pointers to vectors? Pin
markkuk29-Apr-05 10:46
markkuk29-Apr-05 10:46 
GeneralRe: Pointers to vectors? Pin
knapak29-Apr-05 10:54
knapak29-Apr-05 10:54 
GeneralRe: Pointers to vectors? Pin
knapak29-Apr-05 12:45
knapak29-Apr-05 12:45 
GeneralRe: Pointers to vectors? Pin
Stuart Dootson29-Apr-05 22:25
professionalStuart Dootson29-Apr-05 22:25 
GeneralRe: Pointers to vectors? Pin
knapak2-May-05 9:55
knapak2-May-05 9:55 
GeneralRe: Pointers to vectors? Pin
markkuk30-Apr-05 11:56
markkuk30-Apr-05 11:56 
GeneralRe: Pointers to vectors? Pin
knapak2-May-05 9:57
knapak2-May-05 9:57 
QuestionHow do I save/load STL data (map &amp; vector) Pin
Larry Mills Sr26-Apr-05 15:33
Larry Mills Sr26-Apr-05 15:33 
AnswerRe: How do I save/load STL data (map &amp; vector) Pin
Alexandru Savescu28-Apr-05 1:27
Alexandru Savescu28-Apr-05 1:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.