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
 copy selection to layer

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
zorrax Posted - 01/29/2013 : 04:05:52 AM
Origin Ver. and Service Release (Select Help-->About Origin): 8.6
Operating System: Win 7 64b

I would like to copy a selection range from one layer to another one.
I have found some other function to copy to another worksheet or page but not for layer.
what function can I use ?
thank u
4   L A T E S T    R E P L I E S    (Newest First)
Penn Posted - 01/30/2013 : 03:51:04 AM
Hi,

You can use the CopyTo method. Here is the example:

void copy_selected_rows()
{
	WorksheetPage wp = Project.WorksheetPages(0);  // workbook
	if(!wp)
		return;
	Worksheet wks = wp.Layers(0);  // first worksheet in workbook
	if(!wks)
		return;
	
	vector<int> vR1;  // the rows to be selected
	vR1.Add(5);  // indices of some rows to be selected
	vR1.Add(8);
	vR1.Add(14);
	vR1.Add(23);
	wks.SetSelectedRange(vR1);  // highlight the rows
	
	string strNew = "NewWks"; 
	int nn = wp.AddLayer(strNew);  // add a worksheet to workbook
	Worksheet wks2 = wp.Layers(nn);  // get the newly added worksheet
	if(!wks2)
		return;
	
	wks2.SetSize(vR1.GetSize(), wks.GetNumCols());  // set size of the new worksheet
	for(int ii = 0; ii < vR1.GetSize(); ii++)  // loop to copy the selected rows to the new worksheet
	{
		wks.CopyTo(wks2, 0, -1, vR1[ii], vR1[ii] + 1, 0, -1, CPYT_COPY_COLUMN_FORMAT | CPYT_COPY_COLUMN_DESIGNATIONS, ii);
	}
}


Penn
zorrax Posted - 01/29/2013 : 06:09:29 AM
I have found my mistake
I create wks2 as a new one and not as a the wp.layer
zorrax Posted - 01/29/2013 : 05:45:32 AM
thank you for your answer
I know that my question is not clear without example and I am not familiar with the different classes of originC

So I select some row of the sheet1 with this code
WorksheetPage wp = Project.WorksheetPages(0);
wks = wp.Layers(0);
bool bRet = wks.SetSelectedRange(vR1);

then I use the code to create a new page in the worksheetpage pg
int nn = wp.AddLayer(strNew);
Worksheet wks2 = wp.Layers(nn);

and I want to copy selected rows into the wks2
Penn Posted - 01/29/2013 : 05:03:48 AM
Hi,

From the inherit relationship, Worksheet class is actually a child-class of Layer class. And Layer class has three direct child-classes, Datasheet, GraphLayer, and Layout. Then, I am not sure the meaning of copying a selection range from one layer to another one, from Datasheet to Datasheet, or to GraphLayer, or to Layout, or other situation. So, better that you can provide more details on the meaning of "layer", and which function you have found to copy to another worksheet or page. Then I can figure out what you really want.

Penn

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