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 a data from one workbook to another
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

alhelwi

Germany
Posts

Posted - 11/09/2010 :  10:08:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin version 8

i need to copy a data set from Book1 to Book2:
Case 1: same col and rows
Case 2: different row

-------
Case 1:
-------
copy: [Book1][(col=1 to col=30),(row=1 to row=1000)]
To: [Book2][(col=1 to col=30),(row=1 to row=1000)]


-------
Case 2:
-------
copy: [Book1][(col=1 to col=3),(row=1050 to row=2050)]
To: [Book2][(col=32 to col=35),(row=1 to row=1000)]

greg

USA
1378 Posts

Posted - 11/10/2010 :  3:25:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You would think that the second case is the tricky one, but a single Worksheet method handles both cases:

// copy block of data
void copyblock()
{
Worksheet wks1("[Book1]Sheet1");
Worksheet wks2("[Book2]Sheet1");
// Case 1 : Copy
// col1 to col30, row1 to row1000 to col1
wks1.CopyTo(wks2,0,29,0,1000,0,-1,0);
// Case 2 : Copy with shift
// col1 to col3, row1050 to row2050 to col32
wks1.CopyTo(wks2,0,2,1049,2050,31,-1,0);
}
Go to Top of Page

alhelwi

Germany
Posts

Posted - 11/15/2010 :  09:22:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Greg,

thanks for your reply, but it doesn't work!
It gaves me this failure message:
"Member function Worksheet::CopyTo not defined or does not have matching prototype."

If i go to Origin C help, it seems that CopyTo is not a function of the class Worksheet, that's why:
Worksheet wks1("[Book1]Sheet1"); ----> wks1.CopyTo(....);
doesn't work.
As i understood one has to define a Matrix
matrix mat1; ----> mat1.CopyTo(...);

But i still don't understand how the matrix works in order to copy the data.

Thanks in advance for any help!!
Go to Top of Page

Iris_Bai

China
Posts

Posted - 11/15/2010 :  9:01:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Worksheet::CopyTo is a new method added from Origin8 SR5. Please upgrade your Origin.

Iris
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