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