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
 Origin Forum
 The list of sheets name
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

dominik.mierzwa

Poland
119 Posts

Posted - 02/08/2020 :  12:41:31 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2020 (64-bit)
9.7.0.185 (Academic)
Operating System: Windows 10 Pro

Hi,

I Book1 with 3 sheets (name: A, B, C) and Book2 with one sheet (name: report). In column A of the report sheet, I would like to get the names of the sheets from Book1. The script should dynamically change the list after add/remove sheets from Book1.
How to do this? I have tried with page.nlayers and for loop but have no idea how to get the name of particular sheets.

Can you help?



Kind regards,
Dominik

Edited by - dominik.mierzwa on 02/08/2020 1:02:13 PM

cpyang

USA
1406 Posts

Posted - 02/08/2020 :  1:18:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use Range notation to get to a sheet as the wks object, see

https://www.originlab.com/doc/LabTalk/guide/Range-Notation

For example, to get the sheet name of book1 second sheet,

range ww = [book1]2!;
ww.name$=;


See

https://www.originlab.com/doc/LabTalk/ref/Wks-obj


CP
Go to Top of Page

dominik.mierzwa

Poland
119 Posts

Posted - 02/08/2020 :  2:11:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok, I got something like this:
int k =Book1!page.nlayers;
Range Sh=[Book1]$(k)!;
sName$ = Sh.name$;
[Book2]Sheet1!Col(1)[$(k)]=sName$;


But the last line does not work. Moreover, how to put the sName$ in the ""? I'd like to have something like this:
"Sheet1".

Kind regards,
Dominik
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 02/08/2020 :  2:22:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

range bk=[book1];
int kk = bk.nlayers;
range sh = [book1]$(kk)!;
range aa = [book2]sheet1!col(1);
aa[kk]$=sh.name$;


CP
Go to Top of Page

dominik.mierzwa

Poland
119 Posts

Posted - 02/08/2020 :  2:33:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It works perfectly! How about the "". I use this list of sheets as a reference (similar as indirect function in Excel) in the formula:

=[Book1]%(col(A)[i]$)!J1

And if the name is not in "" the formula does not work.

Kind regards,
Dominik

Edit:

SOLVED:

range bk=[book1];
int kk = bk.nlayers;
range sh = [book1]$(kk)!;
range aa = [book2]sheet1!col(1);
string strchar$=char(34)$;
aa[kk]$=strchar$ + sh.name$ + strchar$;

Edited by - dominik.mierzwa on 02/09/2020 04:00:11 AM
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