2.2.4.46.28 Worksheet::GetCellGetCell
Description
Get cell value as a string
Syntax
BOOL GetCell( int nRow, int nCol, string & strText )
BOOL GetCell( int nRow, int nCol, string & strName, TreeNode & tr )
Parameters
- nRow
- [input] Row number with zero offset
- nCol
- [input] Column number with zero offset
- strText
- [output] String to store the value
- nRow
- [input] Row number with zero offset
- nCol
- [input] Column number with zero offset
- strName
- [output] A string to receive the name that the XML tree was saved with during SetCell
- tr
- [output] TreeNode to receive a copy of the tree
Return
TRUE for success, otherwise FALSE
FALSE if the specified cell dose not have associated XML tree, or there is error during retrival, TRUE for success
Examples
EX1
//Get the cell value as a string.
int Worksheet_GetCell_Ex1()
{
WorksheetPage wp = Project.WorksheetPages(0);
if(!wp)
return -1;
Worksheet wks(wp.GetName());
string strText;
int iResult;
wks.SetCell(0, 0, 3.14);
iResult = (int) wks.GetCell(0, 0, strText);
printf("Value at (0,0) location is %s\n", strText);
return iResult;
}
EX2
//Get a copy of the XML tree stored at the specified cell.
int Worksheet_GetCell_Ex2()
{
Worksheet wks = Project.ActiveLayer();
Tree tr;
int nR = 1, nC = 1;
int iResult;
string strName = "bogus";
wks.GetCell(nR, nC, strName, tr);
out_tree(tr);
// next we want to show that we can get the tree into a sub-branch
tr.Junk.ID = 1; // adding a new branch called Junk
// tr.Junk will be replaced, including the tagName,
iResult = (int) wks.GetCell(nR, nC, strName, tr.Junk);
out_tree(tr);
return iResult;
}
Remark
Get a copy of the XML tree stored at the specified cell.
If this function returns FALSE, then you can examine the strName to see if XML tree existed in cell or not. If function returns FALSE and strName is empty, then the cell does not have a tree. If XML tree existed but retrival failed, then function will also return FALSE but strName will not be empty, it will contain the name associated with the XML tree in the cell.
See Also
Datasheet::Cell,Datasheet::SetCell,Datasheet::TCell
Header to Include
origin.h
|