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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 find data sheet name
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

sterw

Netherlands
Posts

Posted - 08/15/2008 :  05:16:36 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

sterw

Netherlands
Posts

Posted - 08/15/2008 :  09:55:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Sim_OriginLab

China
2 Posts

Posted - 08/18/2008 :  02:07:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - Sim_OriginLab on 08/18/2008 04:43:48 AM
Go to Top of Page

sterw

Netherlands
Posts

Posted - 08/18/2008 :  09:13:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Sim_OriginLab

China
2 Posts

Posted - 08/18/2008 :  10:19:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

sterw

Netherlands
Posts

Posted - 08/19/2008 :  05:50:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000