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
 Get red chi sq. from report sheet to another sheet

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
a.abc.b35 Posted - 05/28/2011 : 3:50:07 PM
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
3   L A T E S T    R E P L I E S    (Newest First)
a.abc.b35 Posted - 05/31/2011 : 12:58:31 AM
Thanks a lot Penn. It really helps.

AB
Penn Posted - 05/30/2011 : 05:33:19 AM
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
a.abc.b35 Posted - 05/28/2011 : 3:58:11 PM
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

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