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
 find data sheet name

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
sterw Posted - 08/15/2008 : 05:16:36 AM
Hi,

I want to get the name of the sheet where the input data for a NLFit are located and use that name in Origin C.
I know that after a NLFit the fitted data are written in a sheet in the same workbook as the input data and that the name of that sheet can be found with list vs.
How to use that information in OC to obtain the data sheet name (which is in general (or always?) the first sheet in the workbook) or are there other ways?
I would like to get that name independent of which window happens to be active.

Wim

OriginPro 8 SR2 B891
Windows XP
5   L A T E S T    R E P L I E S    (Newest First)
sterw Posted - 08/19/2008 : 05:50:57 AM
Problem solved.
I used an old sample code and did not realize it was updated in the mean time. The code above gives the expected result.
Thanks
Wim
Sim_OriginLab Posted - 08/18/2008 : 10:19:48 PM
We tested multiple input datas and didn't saw the result as you said.

Could you send us your data (file) and result (project file)?
Tech@originlab.com

Sim
OriginLab Development
sterw Posted - 08/18/2008 : 09:13:29 AM
Thank you. That seems to work.
What I don't understand is the following. When I use your testing sample on my data (standard workbook book1 and sheet1 for data) I get results:
Number of input data: 3
Names of input data sheet:
Sheet1
Sheet1

Why 3 input data and 2 (identical) names?

Wim
Sim_OriginLab Posted - 08/18/2008 : 02:07:40 AM
There is example of Origin C
Input: report worksheet
Output: names of sheet with input datas

bool get_input_worksheet_name(const Worksheet& wksReport, vector<string>& vsInputWks)
{
	Tree trGUI;
	uint 	uid;
	// GRT_TYPE_GUI means get GUI tree of fitting
	// otherwise, GRT_TYPE_RESULTS to get calculation result tree of fitting
	if( !wksReport.GetReportTree(trGUI, &uid, 0, GRT_TYPE_GUI) )
		return false;		

	TreeNode trInput = trGUI.InputData;
	XYRange drXY;
	drXY.Create(trInput, false); // false means data range with multi datas
	
	if ( !drXY || !drXY.IsValid() ) // check error
		return false;
		
	// loop all datasets and get names of sheet one by one
	DWORD dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
	int nNumDataset = drXY.GetNumData(dwRules);
	for (int nIndex = 0; nIndex < nNumDataset; nIndex++ )
	{
		Column colY;
		if ( drXY.GetYColumn(colY, nIndex) )
		{
			Worksheet wks;
			colY.GetParent(wks);
			if ( !wks )
				return false;
			vsInputWks.Add(wks.GetName());
		}
	}
	
	return true;
}


Testing sample

void test_get_fit_sheet()
{
	vector<string> vsInputWks;
	Worksheet wks = Project.ActiveLayer();
	get_input_worksheet_name(wks, vsInputWks);
	
	out_int("Number of input data: ", vsInputWks.GetSize());
	out_str("Names of input data sheet:");
	for (int ii = 0; ii < vsInputWks.GetSize(); ii++ )
	{
		out_str(vsInputWks[ii]);
	}
}

Sim
OriginLab Development
sterw Posted - 08/15/2008 : 09:55:02 AM
As an addition to my question above:
The reason I asked this is because I would like to see a residual plot, including error bars. I know how to do this by copying and pasting from datasheet to fitsheet as was pointed out in http://www.originlab.com/forum/topic.asp?TOPIC_ID=6456, but I would like to have this realized in Origin C as well.

Wim

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