Vector<DOUBLE> ExcelUtils::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;
}