CategoricalData::Attach

Description

Attach a CategoricalData object to an internal Origin data set.


Attach a CategoricalData object to an internal Origin data set by worksheet name and column number.

Syntax

BOOL Attach( LPCSTR lpcszDatasetName, UINT wType = CMT_ORDINAL )

BOOL Attach( LPCSTR lpcszWksName, UINT wColumnNumber, UINT wType = CMT_ORDINAL )

BOOL Attach( Column& col, UINT wType = CMT_ORDINAL )

Parameters

lpcszDatasetName
[Input] name of internal Origin data set
wType
[Input] type of CategoricalMap (only CMT_ORDINAL is supported)

lpcszWksName
[Input] name of internal Origin worksheet
wColumnNumber
[Input] column number in worksheet
col
[Input] column object
wType
[Input] type of CategoricalMap (only CMT_ORDINAL is supported)

Return

True if success else false


True if success else false


True if success else false

Examples

EX1

void CategoricalData_Attach_ex1()
{
    Worksheet wks;
    wks.Create();
    if (wks)
    { 
        Dataset ds(wks, 0);
        ds.SetSize(8);
        vector<string> vs = {"aaa", "bbb", "ddd", "ccc"};
        ds.PutStringArray(vs);

        string strWksColname = wks.Columns(0).GetName();
        strWksColname = wks.GetPage().GetName() + "_" + strWksColname;
        
        StringArray vMyCatMap;
        CategoricalData cdMyCatData;
        cdMyCatData.Attach(strWksColname, CMT_ORDINAL);
        vMyCatMap = (StringArray) cdMyCatData.Map; // Requires explicit cast
    }
}


EX2

void CategoricalData_Attach_ex2()
{
    Worksheet wks;
    wks.Create();
    if (wks)
    { 
        Dataset ds(wks, 0);
        ds.SetSize(8);
        vector<string> vs = {"aaa", "bbb", "ddd", "ccc"};
        ds.PutStringArray(vs);

        string strWksname = wks.GetPage().GetName();
        
        StringArray vMyCatMap;
        CategoricalData cdMyCatData;
        cdMyCatData.Attach(strWksname,0,CMT_ORDINAL);
        vMyCatMap = (StringArray) cdMyCatData.Map; // Requires explicit cast
    }
}

Remark

Attach a CategoricalData object to an internal Origin data set by worksheet name and column number.

See Also

CategoricalData::CategoricalData

header to Include

origin.h