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
 Origin Forum
 Merging Multiple Worksheets into 1

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
masterd Posted - 03/13/2010 : 07:10:50 AM
Origin Ver. and Service Release (Select Help-->About Origin): 7.5 SR5
Operating System: Win7

What is the easiest way to combine/merge multiple worksheets with the same worksheet prefix name?

For example, 20 worksheets named Ave1 through to Ave20 to have all Y columns copied into Ave1 worksheet in the chronological order.

Thanks in advance,

Darko
2   L A T E S T    R E P L I E S    (Newest First)
rlewis Posted - 03/17/2010 : 02:40:25 AM
The Following OC function is designed to collect the columns of all worksheets with names beginning with the characters in the string "strWksStem" into a single newly created worksheet (Returns the name of the new worksheet)

It works in Origin 7.5-SR6 ... Needs a little tweaking though to meet your exact requirements...

string CollectWksCols(string strWksStem)
{
	vector<string> vctWksNames;
	vctWksNames.RemoveAll();
	string strNameStem=strWksStem;
	strNameStem+="*";
	foreach(PageBase pB in Project.Pages)
	{
		if(pB.GetType()==EXIST_WKS)
		{
			string strWksName;
			if(pB.GetName(strWksName)==true)
			{
				if(strWksName.Match(strNameStem)==true)
				{
					vctWksNames.Add(strWksName);
				}
			}
		}
	}
	int NumMatches=vctWksNames.GetSize();
	Worksheet WksDest;
	if(WksDest.Create("origin.otw")==false) goto ErrorExit;
	int nCols=WksDest.GetNumCols()-1;
	for(int i=nCols;i>=0;i--)
	{
		WksDest.DeleteCol(i);
	}
	for(i=0;i<NumMatches;i++)
	{
		Worksheet Wks;
		if(Wks.Attach(vctWksNames[i])==false) goto ErrorExit;
		foreach (Column col in Wks.Columns)
		{
			Dataset dSource(col);
			if(dSource.IsValid()==true)
			{
				int i=WksDest.AddCol();
				if(i==(-1)) goto ErrorExit;
				Dataset dDest;
				if(dDest.Attach(WksDest,i)==false) goto ErrorExit;
				dDest.SetSize(dSource.GetSize());
				dDest=dSource;
			}
		}
			
	}
	if(WksDest.GetNumCols()>0)
	{
		return (WksDest.GetPage().GetName());
	}
	ErrorExit:
	if(WksDest.IsValid()==true)
	{
		WksDest.Destroy();
	}
	return ("");
}


larry_lan Posted - 03/15/2010 : 01:29:39 AM
You should write Origin C or LabTalk Script to implement that.

Larry

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