You may need to do something like ...
void ExtractDataToWks(Worksheet WkSource, vector<uint> StartRow, vector<uint> EndRow, vector<uint> StartCol, vector<uint> EndCol)
{
if(StartRow.GetSize()!= EndRow.GetSize() || StartRow.GetSize()!= StartCol.GetSize() || StartRow.GetSize()!= EndCol.GetSize())
{
out_str("Input vectors StartRow, EndRow, StartCol and EndCol must all be the same size");
return;
}
if(WkSource.IsValid()==false)
{
out_str("Ivvalid Source Worksheet");
return;
}
for(int i=0;i<StartRow.GetSize();i++)
{
vector<uint>RowsToExtract;
uint RowBgn=StartRow[i];
uint RowEnd=EndRow[i];
if(RowBgn>RowEnd)
{
RowBgn=EndRow[i];
RowEnd=StartRow[i];
}
if(RowBgn>=WkSource.GetNumRows() || RowEnd>=WkSource.GetNumRows())
{
out_str("Required Row Extract Range is incompatible with Source Worksheet");
return;
}
RowsToExtract.Data(RowBgn,RowEnd,1);
vector<uint>ColumnsToExtract;
uint ColStart=StartCol[i];
uint ColEnd=EndCol[i];
if(ColStart>ColEnd)
{
ColStart=EndCol[i];
ColEnd=StartCol[i];
}
if(ColStart>=WkSource.GetNumCols() || ColEnd>=WkSource.GetNumCols())
{
out_str("Required Column Extract Range is incompatible with Source Worksheet");
return;
}
ColumnsToExtract.Data(ColStart,ColEnd,1);
WorksheetPage wP;
if(wP.Create("Origin.Otw",CREATE_HIDDEN)==false)
{
out_str("Workbook Creation Error");
return;
}
Worksheet WkDest(wP.Layers(0));
if(WkDest.IsValid()==false)
{
out_str("Output Worksheet Validation Error ...");
return;
}
if(WkSource.Extract(WkDest,RowsToExtract,ColumnsToExtract)==false)
{
out_str("Worksheet::Extract Function Fail ...");
return;
}
}
}