【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。
2.2.4.12.6 Datasheet::FindCol
Contents
Description
Find column in worksheet by searching for column long name. Also applies to MatrixObject in a MatrixLayer.
Syntax
DataObject FindCol( LPCSTR lpcszColLabel, int nColBegin = 0, BOOL bCaseSensitive = false, BOOL bFullMatch = true, int nColEnd = -1, BOOL bAllowShortName = true )
Parameters
- lpcszColLabel
- [input] string to search for column long name, also look for short name if bAllowShortName is true.
- nColBegin
- [input] Column index (0 offset) to start searching. Its default value is 0.
- bCaseSensitive
- [input] TRUE if case sensitive. Its default value is false.
- bFullMatch
- [input] FALSE if only match substring, must set to TRUE if bAllowShortName is used. Its default value is true.
- nColEnd
- [input] End of Column index for searching, when it is -1, search till the last of column. Its default value is -1.
- bAllowShortName
- [input] first check short name if true, when false, short name is ignored. Its default value is true.
Return
A DataObject object
Examples
EX1
void Datasheet_FindCol_Ex1() { Worksheet wks; wks.Create(); wks.AddCol(); wks.Columns(0).SetLabel("AA01"); wks.Columns(1).SetLabel("AA"); wks.Columns(2).SetLabel("aa"); wks.Columns(2).SetName("Test"); wks.ShowLabels(); // search whole worksheet for label is "aa" without case sensitive Column col = wks.FindCol("aa"); // should be 2nd column "AA" if( col ) printf("1. The label of the column is %s.\n", col.GetLabel()); else printf("1. Fail to find column.\n"); // search whole worksheet for label is "aa" with case sensitive col = wks.FindCol("aa", 0, true); // should be 3th column "aa" if( col ) printf("2. The label of the column is %s.\n", col.GetLabel()); else printf("2. Fail to find column.\n"); // search whole worksheet for label is "aa" without full match col = wks.FindCol("aa", 0, false, false); // should be 1st column "AA01" if( col ) printf("3. The label of the column is %s.\n", col.GetLabel()); else printf("3. Fail to find column.\n"); // search whole worksheet for short name is "aa" without case sensitive col = wks.FindCol("Test", 0, false, true, -1, true); // should be 3th column "aa" if( col ) printf("4. The label of the column is %s.\n", col.GetLabel()); else printf("4. Fail to find column.\n"); }
void MatrixObject_FindCol_Ex1() { //before running this code, make sure the active matrixsheet contain multiple matrixobjects and renamed with special names, e.g "rr", "pp" MatrixLayer ml = Project.ActiveLayer(); if ( !ml ) { printf("Can not access active matrixsheet"); return; } string strObjName = "rr"; MatrixObject mo = ml.FindCol(strObjName); if ( mo ) out_str("Find the matrixobject named " + mo.GetName()); strObjName = "Rr"; mo = ml.FindCol(strObjName, 0, true); //case sensitive if ( mo ) out_str("Find the matrixobject named " + mo.GetName()); strObjName = "r"; mo = ml.FindCol(strObjName, 0, true, false); //not full match if ( mo ) out_str("Find the matrixobject named " + mo.GetName()); strObjName = "pp"; mo = ml.FindCol(strObjName, 0, true, true, -1, false); if ( mo ) out_str("Find the matrixobject named " + mo.GetName()); return; }
Remark
See Also
Header to Include
origin.h