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
 Origin Forum
 Merging Multiple Worksheets into 1
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

masterd

Australia
Posts

Posted - 03/13/2010 :  07:10:50 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

larry_lan

China
Posts

Posted - 03/15/2010 :  01:29:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You should write Origin C or LabTalk Script to implement that.

Larry
Go to Top of Page

rlewis

Canada
253 Posts

Posted - 03/17/2010 :  02:40:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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 ("");
}


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