check_cols_in_range_with_same_datatype

 

Description

Check whether all columns in selected data range have same data type or not.

Syntax

bool check_cols_in_range_with_same_datatype( DataRange & dr, int * pType = NULL )

Parameters

dr
[input] The data range selected.
pType
[output] pointer to columns type. its default is NULL. if not NULL and the data range have same data type, pType will get the type. else pType will get the type which should be set.(for detail please see set_cols_in_range_to_same_datatype).

Return

If same return ture, otherwise return false.

Examples

EX1

void check_cols_in_range_with_same_datatype_Ex1()
{     
        Worksheet wks;
    wks.Create("Origin");
    if( wks )
    {
                DataRange dr;
                dr.Add(wks, 0, "X");
                dr.Add(wks, 1, "Y");
                
                if(check_cols_in_range_with_same_datatype(dr)) // returns true since column default data type is double
                    printf("columns in selected data range have same data type\n");
                else
                    printf("columns in selected data range have NOT same data type\n");
                
                // set two columns to different data type
                wks.Columns(0).SetFormat(OKCOLTYPE_NUMERIC);         
                wks.Columns(1).SetFormat(OKCOLTYPE_NUMERIC);         
                wks.Columns(0).SetInternalDataType(FSI_LONG);                
                wks.Columns(1).SetInternalDataType(FSI_DOUBLE);
                
                if(check_cols_in_range_with_same_datatype(dr)) // returns false
                    printf("columns in selected data range have same data type\n");
                else
                    printf("columns in selected data range have NOT same data type\n");       
    }
}

Remark

See Also

set_cols_in_range_to_same_datatype

header to Include

origin.h

Reference