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
 How to duplicate SHEET ih the same BOOK in OriginC

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
Alex-qwerty Posted - 01/29/2010 : 08:02:03 AM
Origin Ver.: OriginPro 8.0 SR6
Operating System: WinXP SP2

How can I do in OriginC the same action as can I do by context menu of worksheet name "Duplicate Without Data"?
I tried to use Worksheet.CreateCopy(), but it creates a new WorkBook instead a new WorkSheet in the same WorkBook.
I want to create a new Sheet with the same structure with new Name an
d without data.
Thanks.
1   L A T E S T    R E P L I E S    (Newest First)
rlewis Posted - 02/01/2010 : 11:12:29 AM
Probably not the most effecient way of doing it ... but it seems to work ..

	int WksDuplicate(Worksheet Wks, WorksheetPage &WPuser=NULL)
	{
	/*
		Create a duplicate of the  WorkSheet Wks as as a new sheet within the Parent Workbook Object  ... (WPuser=NULL)
		or the User-supplied Workbook Object "WPuser!=NULL"
		Returns the index of the newly created Worksheet
	*/		
		if(Wks.IsValid()==true)
		{
			WorksheetPage wpDest;
			if(WPuser==NULL)
			{
				wpDest=Wks.GetPage();
			}
			else
			{
				wpDest=WPuser;
			}
			if(wpDest.IsValid()==true)
			{
				return (wpDest.AddLayer(Wks));
			}
		}
		return (-1);
	}
	
	bool WksClear(Worksheet Wks, int Reduce=1, int SetAsBlank=1, int WarnMsg=0)
	{
	/*
		Clears the Data from the Worksheet Wks
		For info on the other parameters see the xFunction "wclear"
	*/		
	if(Wks.IsValid()==true)
	{
		string strXFname="wclear";
		XFBase xfwclear(strXFname);
		if(xfwclear)
		{
			if(xfwclear.SetArg("w",Wks)==true && xfwclear.SetArg("reduce",Reduce)==true && xfwclear.SetArg("op",SetAsBlank)==true && xfwclear.SetArg("msg",WarnMsg)==true)
            {
            	if(xfwclear.Evaluate()==true)
				{
					foreach (Column Col in Wks.Columns)
					{
						Col.SetLongName("");
					}
					return (true);
				}
            }
		}
	}
	return (false);
}

	void CreateNewSheet()
	{
		/*
			Creates a new sheet within the same workbook using he current worksheet as a template ...
		*/
		Worksheet Wks(Project.ActiveLayer());
		if(Wks.IsValid()==true)
		{
			int iLayr=WksDuplicate(Wks);
			if(iLayr>=0)
			{
				WorksheetPage Wpg=Wks.GetPage();
				if(Wpg.IsValid()==true)
				{
					Worksheet Wks1(Wpg.Layers(iLayr));
					WksClear(Wks1);
				}
			}
		}
	}

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