set_cols_in_range_to_same_datatype

 

Description

Set all columns in selected data range to the same data type if columns have different data type.

Syntax

int set_cols_in_range_to_same_datatype( DataRange & dr, int * pType = NULL )

Parameters

dr
[input] The data range selected.
pType
[input] pointer to columns' type.
If not NULL, all columns' type will set to pType. Otherwise, if one column's type is double, real, Complex or mixed(numeric &text, which is column's default setting), all columns' type will be set to double. Default is NULL.

Return

if succeed return the type value, otherwise return -1.

Examples

EX1

void set_cols_in_range_to_same_datatype_Ex1()
{
        
        Worksheet wks;
        wks.Create("Origin");
        if( wks )
        {
                DataRange dr;
        
                dr.Add(wks, 0, "X");
                dr.Add(wks, 1, "Y");
        
                // 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);
                int nRet = set_cols_in_range_to_same_datatype(dr);
                if(nRet < 0)
                        printf("failed to set");
                else
                        printf("columns in selected data range are all set to same type \n" );
        
        }   

}

Remark

See Also

check_cols_in_range_with_same_datatype

header to Include

origin.h

Reference