3.2.7.1 Column Name and Labels
Version Info
Minimum Origin Version Required: Origin8 SR0
Get Column Short Name
You can use Column::GetName to get the short name of columns.
Set Column Short Name
This example shows how to set the short name of columns in the worksheet.
void column_set_short_name_ex()
{
WorksheetPage wp;
wp.Create("Origin");
Worksheet wks(wp.GetName());
//Create a Column and attach it to column 1 in the worksheet
Column colA;
colA.Attach(wks, 0);
colA.SetName("myColA"); //Set short name to "myColA"
printf("column 1 has the short name %s\n", colA.GetName());
//Create a Column and attach it to column 2 in the worksheet
Column colB;
colB.Attach(wks, 1);
colB.SetName("myColB"); //Set short name to "myColB"
printf("column 2 has the short name %s\n", colB.GetName());
}
Get Column Long Name
You can use Column::GetLongName to get the long name of columns.
Set Column Long Name
This example shows how to set the long name of columns in the worksheet.
void column_set_long_name_ex()
{
WorksheetPage wp;
wp.Create("Origin");
Worksheet wks(wp.GetName());
wks.AddCol(); //Add one more column
//set the long name of columns
wks.Columns(0).SetLongName("Start of Run");
wks.Columns(1).SetLongName("Yield at Stage 1");
wks.Columns(2).SetLongName("Yield at Stage 2");
//get the long name of columns
for( int ii = 0; ii < wks.GetNumCols() ; ii++ )
{
printf("Column %d has the long name '%s'\n", ii + 1, wks.Columns(ii).GetLongName());
}
}
Get Column Units
You can use Column::GetUnits to get the Units of columns.
Set Column Units
This example shows how to set Units of columns.
void column_set_units_ex()
{
Worksheet wks;
wks.Create("Origin");
if(!wks)
return;
wks.Columns(0).SetUnits("msec"); //Set units of column 1 to msec
wks.Columns(1).SetUnits("ft-lbs"); //Set units of column 2 to ft-lbs
}
Get Column Comments
You can use Column::GetComments to get the Comments of columns.
Set Column Comments
This example shows how to set comments of columns.
void column_set_comments_ex()
{
Worksheet wks;
wks.Create("Origin");
if(!wks)
return;
wks.Columns(0).SetComments("Product Code\nColor");//Set comments of column 1
wks.Columns(1).SetComments("HG42\nRed");//Set comments of column 2
}
Get Column Extended Labels
You can use Column::GetExtendedLabel to get the extended label by type of extended label.
Set Column Extended Labels
This example shows how to show specified column labels, change lable header name and set label text by type of extended label.
void column_set_extended_labels_ex()
{
Worksheet wks;
wks.Create("Origin"); // create a worksheet
Grid grid;
grid.Attach(wks); // grid attach to worksheet
vector<int> vnTypes = {RCLT_LONG_NAME, RCLT_UNIT, RCLT_COMMENT, RCLT_PARAM, RCLT_PARAM+1, RCLT_UDL, RCLT_UDL+1};
grid.SetShowLabels(vnTypes); // set which types of label should be shown
// Set row header of the user-defined label. Default is User-Defined Parameters
vector<string> vsLabels = {"User-Defined 1", "User-Defined 2"};
grid.SetUserDefinedLabelNames(vsLabels);
Column col(wks, 0); // set text to the following labels for the first column
col.SetExtendedLabel("Long Name", RCLT_LONG_NAME); // set long name
col.SetExtendedLabel("Unit", RCLT_UNIT); // set units
col.SetExtendedLabel("Comment\nAnd more...", RCLT_COMMENT); // set comments of column 1. Only Comments can be multilined, \n is the line separator.
col.SetExtendedLabel("Param1", RCLT_PARAM); // set parameters label
col.SetExtendedLabel("Param2", RCLT_PARAM+1); // set parameters 2 label
col.SetExtendedLabel("User1", RCLT_UDL); // set user-defined 1 label
col.SetExtendedLabel("User2", RCLT_UDL+1); // set used-defined 2 label
wks.AutoSize(); // auto resize worksheet to show all text in column labels
}
|