DataRange::Merge
Merge
Description
Merge another DataRange into this DataRange.
Syntax
BOOL Merge( DataRange & range )
Parameters
- range
- [modify]the DataRange that would be merged,after this operation,it will be invalid object
Return
TRUE if successful.
Examples
EX1
// This example show that merge datarange, then get the minimum and maximum of the data.
void DataRange_Merge_Ex1(int nXCol = 0, int nY1Col = 1, int nY2Col = 2)
{
//Create a worksheet with three columns.
Worksheet wks ;
wks.Create();
if( wks )
{
while(wks.Columns(0))
wks.DeleteCol(0);
wks.AddCol("A");
wks.AddCol("B");
wks.AddCol("C");
double rr;
for(int j=0;j<3;j++)
for (int i=0;i<10;i++)
{
rr=rnd();
wks.SetCell(i,j,rr*100);
}
DataRange dr, drX, drY1, drY2;
drX.Add("X", wks, 0, nXCol, -1, nXCol);
drY1.Add("Y", wks, 0, nY1Col, -1, nY1Col);
drY2.Add("Y", wks, 0, nY2Col, -1, nY2Col);
DWORD dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
DWORD dwPlotID; // This is to retrieve DataPlot UID if present
vector vData;
double dmin, dmax;
string strRange;
//dr.Reset();
dr.Merge(drX);
dr.Merge(drY1);
dr.GetData(DRR_NO_FACTORS, 0, &dwPlotID, NULL, &vData);
// Now we have made a copy of data into vector vData
// so we can do analysis on the data...for example:
vData.GetMinMax(dmin, dmax);
strRange = dr.GetDescription();
printf("%s\nmin = %g\nmax = %g\n", strRange, dmin, dmax);
dr.Reset();
dr.Merge(drX);
dr.Merge(drY2);
dr.GetData(DRR_NO_FACTORS, 0, &dwPlotID, NULL, &vData);
// Now we have made a copy of data into vector vData
// so we can do analysis on the data...for example:
vData.GetMinMax(dmin, dmax);
strRange = dr.GetDescription();
printf("%s\nmin = %g\nmax = %g\n", strRange, dmin, dmax);
}
}
Remark
See Also
header to Include
origin.h
|