Author |
Topic |
|
kdsaransh
India
89 Posts |
Posted - 12/23/2014 : 02:22:12 AM
|
Hello,
I am using origin 9.1. I want to copy the long name and comment of a worksheet to the column of another workbook using script, but i am unable to do so. Please help me out.
Regards, Rajesh Agarwal |
Edited by - kdsaransh on 12/23/2014 02:27:25 AM |
|
lkb0221
China
497 Posts |
|
kdsaransh
India
89 Posts |
Posted - 12/23/2014 : 11:21:26 AM
|
Hi Zheng,
Sorry for the confusion. But i don't want to copy the entire worksheet. So the problem is as follows:
I have a workbook (book1) having a sheet (sheet1). This sheet1 contains some data in some columns and each column has a long name, units and comments. Now i want to copy the long name/unit/comment of a specified column in sheet1 to the specified column of another sheet1 of another workbook (book2).
Thanks for your reply...
Regards,
|
|
|
lkb0221
China
497 Posts |
Posted - 12/23/2014 : 11:33:14 AM
|
Hi, kdsaransh
Then use the following sample: // Start range r1 = [book1]Sheet1!col(A); // Point to the source column range r2 = [Book2]Sheet2!col(B); // Point to the target column r2[L]$ = r1[L]$; // Copy the LongName r2[U]$ = r1[U]$; // Copy the Unit r2[C]$ = r1[C]$; // Copy the Comment // End
Or, use colcopy XF: // Start range r1 = [book1]Sheet1!col(A); // Point to the source column range r2 = [Book2]Sheet2!col(B); // Point to the target column colcopy irng:=r1 orng:=r2 data:=0 format:=0; // Copy column with out data, no recalculation // End
Zheng OriginLab |
|
|
kdsaransh
India
89 Posts |
Posted - 12/23/2014 : 11:41:26 AM
|
Thanks for the reply, but this is not i want.
I want to copy the long name of a sheet to a row of a column . For ex: the long name of the data in sheet1 and in column (A) is " voltage". Now i want to copy this long name to another sheet of a different workbook in column (B), but in row 1.
Thanks .
|
|
|
lkb0221
China
497 Posts |
Posted - 12/23/2014 : 12:07:00 PM
|
// Start range r1 = [book1]Sheet1!col(A); // Point to the source column range r2 = [Book2]Sheet2!col(B); // Point to the target column r2[1]$ = r1[L]$; // Copy the LongName // End |
|
|
kdsaransh
India
89 Posts |
Posted - 12/23/2014 : 12:17:54 PM
|
Thanks a lot. You really solved my problem. I now know what silly mistake i was doing.
It will more to ask , i know , but since i am very new to lab talk, so if you could also help me out for the following:
I want to put this command in a loop. i mean to say that now i want to copy multiple column long name of a sheet to the row (row 1, row 2, row 3 etc) of another sheet.
please....
thanks once again. ...
|
|
|
lkb0221
China
497 Posts |
Posted - 12/23/2014 : 2:05:23 PM
|
Hi, For example, to copy all long names from a worksheet: // Start range r1 = [Book1]Sheet1!; // Source Worksheet range r2 = [Book2]Sheet2!col(A); // Target Column for (int ColNum = 1; ColNum <= r1.ncols; ColNum++) { r2[ColNum]$ = r1.col$(ColNum).lname$; } // End
In this sample, I used wks.col.lname$ to access column long name. It is a old method but is easier for writing the loop. wks.col can only access long name, short name, unit and comment. For other labels, you will need to use notations like Col(A)[L]$.
Zheng OriginLab |
Edited by - lkb0221 on 12/23/2014 2:05:59 PM |
|
|
kdsaransh
India
89 Posts |
Posted - 12/24/2014 : 09:57:56 AM
|
Thank you so much for the help. It really solved my problem a lot. |
|
|
|
Topic |
|