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 for Programming
 Forum for Origin C
 Copy and past a row in the same worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Fry

Germany
5 Posts

Posted - 10/04/2016 :  06:32:31 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2015G (64-bit) Sr2 b9.2.272
Operating System: Windows 7

Hello Origin community,

is there a recommended way to copy one row of the worksheet to another row of the same worksheet?
I tried Worksheet::CopyTo, but as mentioned in the description i works only for the copy to another worksheet.

The code I had tried is:


	int  iRetFkt;
	
	DWORD dwCtrl = CPYT_COPY_COLUMN_FORMAT | CPYT_COPY_COLUMN_DESIGNATIONS;

	Worksheet wksAkt = Project.ActiveLayer();
	

	iRetFkt = wksAkt.CopyTo(wksAkt, 0,  -1,   0,   1,    0, -1, dwCtrl, 5);

	if(iRetFkt != 0){
		out_int("Error = ", iRetFkt);
	}


Thank you for the support!
René

Edited by - Fry on 10/04/2016 09:58:17 AM

yuki_wu

896 Posts

Posted - 10/09/2016 :  03:40:38 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Perhaps you can try this example:


void Worksheet_CopyTo_Ex2()
{
	Worksheet wksSource = Project.ActiveLayer();
	if( wksSource )
	{
		int nC1 = 0, nC2 = -1; 
		// The source ending row (nR2) is exclusive
		int nR1 = 2, nR2 = 4;
		//Copy to the worksheet starting at the 12th column
		int nDestR1 = 12;
		
		DWORD dwCtrl = CPYT_APPEND_BY_ROW | CPYT_ALLOW_SAME_LAYER_IF_NOT_INTERSECT;
		int nRet = wksSource.CopyTo(wksSource, nC1, nC2, nR1, nR2, 0, -1, dwCtrl, nDestR1); 
	}
}


Hope this can be some help.

Regards,
Yuki
OriginLab
Go to Top of Page

Fry

Germany
5 Posts

Posted - 10/10/2016 :  11:54:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Yuki,

thanks a lot! It's my fault, I didn't look at the CPYT_* in oc_const.h! Now it works fine for me.

Regards,
Fry
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