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
 Get red chi sq. from report sheet to another sheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

a.abc.b35

175 Posts

Posted - 05/28/2011 :  3:50:07 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8,SR0
Operating System: win 7
................
I have written the following code (attached at end). But instead of getting the value ( say 0.0018) , I get cell://FitNL1!RegStats.C1.ReducedChiSq written at the 2nd column of the output worksheet. Instead, if I comment out the red part and use the blue part (both below in the code) of the code, then I get the value (0.0018) at the 2nd column of the output worksheet. In this case the output worksheet is created at the end of the same workbook where from the values are collected ( the only difference according to me). Can anyone please point out what is happening and tell me how to get the value in a separate worksheet( in a separate workbook,like if I un-comment the red part and comment out the blue part of the code) ?

#include <origin.h>
bool zz()
{
	// name of the workbook to collect data
	string wpName1;
	// enter Workbook whose FiTNL worksheets are to be scanned for values
	wpName1 = InputBox("Please enter the WorkBook name to collect data ", "data");
	if(wpName1.IsEmpty())  // executed if user does not enter anything in the InputBox pop up window
    {
      	printf("Try again.Enter a workbook name next time.Operation Cancelled!\n");
      	return false;
    } 
            
    else
    {
		WorksheetPage wp(wpName1);
		vector<string> RCS;
		vector<string> wksName;
    	printf("Below are the FitNL files which has been scanned for the parameter values:\n");
    	// loop all worksheets in the workbook, add plots to graph
    	for(int iwks = 0; iwks <wp.Layers.Count();iwks++)
    	{	
    
    		Worksheet wks = wp.Layers(iwks);
       		uint uid;
			Tree tr;
			
			if(wks.GetReportTree(tr, &uid, 0, GRT_TYPE_RESULTS, true))
			{
				out_str(wks.GetName());
				
				wksName.Add(wks.GetName());
		
				//out_tree(tr);  // can output the tree to see the results
	 	
				// after the particular fit, put the parameters to vector (change here for different fitting functions)
				// for Red. Chi sq. There definitely exista a better and direct method. But this works!
				string strCellPrefix;
				
				strCellPrefix.Format("cell://%s!", wks.GetName());
				RCS.Add(strCellPrefix + "RegStats.C1.ReducedChiSq");
			
			}
    	}
    	
    	// create workbook,worksheet and put to columns
    	Worksheet wksOut;
    	wksOut.Create();
    	set worksheet name
    	wksOut.SetName("Result1");
    	set workbook name
    	wksOut.GetPage().SetName("Result");
		
    	//int index = wp.AddLayer();
	//Worksheet wksOut = wp.Layers(index);
    	
    	Column colwksName(wksOut, 0);
    	Column colRCS(wksOut, 1);
    	colwksName.PutStringArray(wksName);
		colRCS.PutStringArray(RCS);

		return true;
    }
}



AB

a.abc.b35

175 Posts

Posted - 05/28/2011 :  3:58:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In above post, in the part in red, "set worksheet name" and "set workbook name" are comments (like shown below). Sorry about that. Anyways, the problem stays same.

Worksheet wksOut;
wksOut.Create();
//set worksheet name
wksOut.SetName("Result1");
//set workbook name
wksOut.GetPage().SetName("Result");


AB
Go to Top of Page

Penn

China
644 Posts

Posted - 05/30/2011 :  05:33:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi AB,

In your code, you want to make a link to the report worksheet, so to get the result shown in a different workbook. However, you have missed the workbook name when you construct the link (the following two lines).

strCellPrefix.Format("cell://%s!", wks.GetName());
RCS.Add(strCellPrefix + "RegStats.C1.ReducedChiSq");

You can change like below to include the book name:

strCellPrefix.Format("cell://[%s]%s!", wks.GetPage().GetName(), wks.GetName());
RCS.Add(strCellPrefix + "RegStats.C1.ReducedChiSq");


Penn
Go to Top of Page

a.abc.b35

175 Posts

Posted - 05/31/2011 :  12:58:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot Penn. It really helps.

AB
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