The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Range String Pointing to a Worksheet Text Cell

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
cdrozdowski111 Posted - 08/06/2013 : 07:18:28 AM
OriginPro 9.0.0 SR2 64-bit, Win7 64-bit, running in VMware Fusion 5.0.3

I'm working on an OC function that puts text into a worksheet text cell. A string param containing the range to the cell is passed into the function as well as the text to put in the cell.

How can I determine if the range string points to a valid text cell? And how do I add the text to the cell?


void myText2Cell(string strCellRng, string strText)
{
	// Determine if the string strCellRng points to a valid text cell in a worksheet

	// If so, put strText in that cell
}
1   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 08/06/2013 : 10:44:49 PM
Hi,

Maybe you need to parse the range string to judge if it points to a valid cell. You can refer to the following example.

void myText2Cell(string strCellRng = "[Book1]1!Col(B)[2]", string strText = "My Text")
{
	bool isValid = false;  // whether the cell range is valid
	DataRange dr;
	int nn = dr.Add("X", strCellRng);  // try to add data range by using the range string
	if(nn > 0 && !dr.IsEmpty())  // if added successfully
	{
		int nrc[4];
		Worksheet wksRet;
		// find the worksheet, row index, column index
		if(find_input_range_bounding_box(dr, nrc[0], nrc[1], nrc[2], nrc[3], wksRet, 0, "X"))
		{
			int nRows = wksRet.GetNumRows();  // number of rows in worksheet
			Column col(wksRet, nrc[1]);  // column
			if(col && nRows > nrc[0])  // if column is valid, and row is valid
			{
				isValid = true;  // set to true
				wksRet.SetCell(nrc[0], nrc[1], strText);  // set string to cell
			}
		}
	}
	if(!isValid)
	{
		printf("%s is not a valid range to the cell!", strCellRng);
	}
}


Penn

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000