Copy numeric data from source columns/rows to destination columns/rows
1. copydata irng:=col(1) orng:=col(2) clear:=1; //Copy data from column 1 to col 2 first clearing col 2.
2. copydata irng:=[Book1]Sheet1!col(2)[4] orng:=[Book2]Sheet1!col(2)[4]; // Copy row 4 of col 2 of sheet1 in Book1 to same place in Book2.
3. copydata irng:=([Book1]Sheet1!2[5]:3[11],[Book1]Sheet1!3[3]:4[8]) orng:=[Book2]Sheet1!3[4:4] clear:=1; // Copies non-congruous data from one book to another, rearranging in process.
Please refer to the page for additional option switches when accessing the x-function from script
Input
Range
Output
See the syntax here.
int
This function copies numeric data between a source range and a destination range. If there is non-numeric data in the source range, Origin will not copy the non-numeric data. Rather, it will set the destination cells to missing values. Note: This X-function only copies data and not any label row contents or formatting.
// In this example we use copydata to copy an column of data to a new worksheet then break the column into ten separate columns. newbook; // Create a new workbook. col(1) = data(1,100); // Fill column with row numbers from 1 to 100. range r1 = 1; // Range is column 1 of this sheet. newsheet; // Add a new sheet and activate. range r2 = 1; // Range is column 1 of new sheet. copydata irng:=r1 orng:=r2 clear:=1; // Copy column 1 from first sheet to second sheet clearing that columns fist. wks.ncols = 10; // Add some columns // Now rearrange the first column in second sheet into ten different columns of ten rows each. loop(ii, 2, 10) { // Below notice how the columns are referenced by column number 1 signifies the 1st column // and $(ii) represents cols 2 to 8 as loop progresses. // The orng destination only needs the first row specified and the rest of rows will be automatically filled. copydata irng:=1[$(10*(ii-1)+1):$(10*ii)] orng:=$(ii)[1]; ii++; } mark -d col(1) -b 11 -e 100; // Delete the extraneous rows left over in column 1.