2.2.4.5.49 Column::SetFormat

Description

Set the column format.

Syntax

BOOL SetFormat( int iFormat, int nSubformat = -1, BOOL bUndo = FALSE )


BOOL SetFormat( int iFormat, LPCSTR lpcszCustomFormat, BOOL bUndo = FALSE )

Parameters

iFormat
[input] the column format,enum {
OKCOLTYPE_NUMERIC,
OKCOLTYPE_TEXT,
OKCOLTYPE_TIME,
OKCOLTYPE_DATE,
OKCOLTYPE_MONTH,
OKCOLTYPE_WEEKDAY,
OKCOLTYPE_COLUMN,
OKCOLTYPE_DATASET,
OKCOLTYPE_DATASET_X,
OKCOLTYPE_TEXT_NUMERIC,
OKCOLTYPE_CATEGORICAL,
OKCOLTYPE_PERCENTAGE,
OKCOLTYPE_CURRENCY,
OKCOLTYPE_STROBJ }
nSubformat
[input] The integer (enumerated from zero) of the subformat for the current column type, -1 means set format only.
bUndo
[input] if bUndo is true, you can use Ctrl + Z to undo SetFormat.


iFormat
[input] the column format, OKCOLTYPE_*
lpcszCustomFormat
[input] the custom date display string.
bUndo
[input] if bUndo is true, you can use Ctrl + Z to undo SetFormat.

Return

TRUE, set the coloumn format successfully, FALSE, unsuccessful.

Examples

EX1

// Worksheet with at least one column must exist in project
void    Column_SetFormat_Ex1()
{
    WorksheetPage wp = Project.WorksheetPages(0);
    if(!wp)
        return;
    
    Worksheet wks(wp.GetName());
    printf("Format of column %s is of type %u\n", wks.Columns(0).GetName(), wks.Columns(0).GetFormat());
    printf("Setting to Numeric (0)\n");
    BOOL b = wks.Columns(0).SetFormat(OKCOLTYPE_NUMERIC);
    printf("Format of column %s is of type %u\n", wks.Columns(0).GetName(), wks.Columns(0).GetFormat());
}


EX2

void SetFormat_ex1()
{
	Worksheet wks = Project.ActiveLayer();
	Column col(wks, 0);
	col.SetFormat(OKCOLTYPE_DATE, "yyyy'-'MM'-'dd");
}
void SetFormat_ex2()
{
	Worksheet wks = Project.ActiveLayer();
	Column col(wks, 1);
	col.SetFormat(OKCOLTYPE_TEXT_NUMERIC, "DMS2");
}
void SetFormat_ex3()
{
	Worksheet wks = Project.ActiveLayer();
	Column col(wks, 2);
	col.SetFormat(OKCOLTYPE_TIME, "hh mm ss'.'##");
}

Remark

Set the column format.

See Also

Column::GetFormat, Column::SetSubFormat
Column::SetCustomDisplay

Header to Include

origin.h