2.1.7.8 get_xy_data


Description

Get xy data from data range

Syntax

bool get_xy_data( const DataRange & dr, vector & vx, vector & vy, int * pi1 = NULL, int * pi2 = NULL, bool bGetMissingValues = true, Worksheet * pwks = NULL )

Parameters

dr
[input] the input data range object
vx
[output] to hold x data got from data range
vy
[output] to hold y data got from data range
pi1
[output] the start row's index of a column in the data range
pi2
[output] the end row's index of a column in data range, -1 for the last row.
bGetMissingValues
[input] if false, will trim missing values
pwks
[output] the worksheet that this data range selected form

Return

Returns true if succeed, otherwise false.

Examples

EX1

void get_xy_data_Ex1()
{
    Worksheet wks;
    wks.Create("origin");
    Dataset ds1(wks,0);
    Dataset ds2(wks,1);
    ds1.Data(1,20,1);
    ds2.Data(20,1,-1);
    
    DataRange dr;
    dr.Add(wks, 0, "X");
    dr.Add(wks, 1, "Y");
    
    vector     	vX, vY;
    int        	pi1 = 0, pi2 = 0;
    bool    	bGetMissingValues = false;
    Worksheet   wksRet;
    bool bRet = get_xy_data(dr, vX, vY, &pi1, &pi2, bGetMissingValues, &wksRet);
    if(bRet)
    {
    	printf("Got X data in vX, the size of vX = %d\n", vX.GetSize());
    	printf("Got Y data in vY, the size of vY = %d\n", vY.GetSize());
    	printf("start row index pi1= %d, end row index pi2 = %d\n", pi1, pi2);
    }
    else
        printf("Failed to get\n");    

}

Remark

See Also

get_data_from_dr_to_mat

Header to Include

origin.h

Reference