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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 how to export multiple worksheets?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
daliss Posted - 03/22/2006 : 07:04:09 AM
Origin Version (Select Help-->About Origin): Pro7.5
Operating System:XP

Hello All

I want to export multiple worksheets to respective ASCII files. I can use "save -w wksName fileName" to export one worksheet. But I don't know how to get those worksheets names and save them to ASCII files? For example, I open a project including three worksheets which names are B1,D2 and E3£¬respectively. My purpose is converting B1,D2,E3 worksheets to B1.txt,D2.txt and E3.txt.

Thanks for any suggestions.

Sincerely

William Peng
11   L A T E S T    R E P L I E S    (Newest First)
Whydoge Posted - 08/19/2021 : 10:37:37 AM
Hello,
id like to ask an additional question:
Origin 8.6

I want to export from multiple Books (which are in one folder inside an origin project).
I can do that using the commands you have kindly supplied herein already (fdlog.openpath(B); doc -ef W{save -w %H %B%H.txt};)
However, I have 3 sheets in each book - I need to export only the second sheet from all the books.
Ideally, only the colums 1,2, 4, 6, and 8. If that is possible in any way?

Much thank you for your help.
Whydoge
yuki_wu Posted - 02/28/2017 : 05:19:32 AM
Hi Matthias,

Thank you for correcting! How careless I was.

I found some pages that may help you to understand the scripts:

1. Loop over workbook and worksheet
http://www.originlab.com/doc/LabTalk/guide/Looping-Over-objs#Looping_over_Workbooks_and_Worksheets
2. Page object
http://www.originlab.com/doc/LabTalk/ref/Page-obj
3. WKS object
http://www.originlab.com/doc/LabTalk/ref/Wks-obj
4. String Registers as System Variables(for example: %H)
http://www.originlab.com/doc/LabTalk/guide/String-registers

Regards,
Yuki
OriginLab
M.Steidl Posted - 02/28/2017 : 05:07:02 AM
Hello,

thank you, yuki, for your help. You made a small spelling error in "page.longname$": you had an "a" instead of "g". I corrected it and now it works fine.
The final command is the following:

fdlog.openpath(B); // choose directory

doc -e W{
doc -e LW
{
string temp1$ = page.longname$; // Get workbook name
string temp2$ = wks.longname$; // Get worksheet longname (replace by wks.name for shortname)
expASC path:=%B%(temp1$)_%(temp2$);
};
}

I'm surprised though that "page" refers to the workbook. How can I understand that and where could I read more about that topic?

best regards,
Matthias
yuki_wu Posted - 02/28/2017 : 01:43:53 AM
Hi,

You are right. You can just replace %H as follows:

string temp1$ = page.longname$;
string temp2$ = wks.longname$;
expASC path:=%B%(temp1$)_%(temp2$); 

Hope it helps.

Regards,
Yuki
OriginLab
M.Steidl Posted - 02/27/2017 : 12:16:00 PM
Origin Version 9.1.0G (64-bit) Sr1
Operating System:Windows7

Hello all,

I would like to export all worksheets in all workbooks with name as "WORKBOOK LONGNAME_ WORKSHEET LONGNAME"

How do I have to adjust the code of SeanMao posted 04/27/2016 or the code of Mike Buess posted 03/22/2006 ?
I guess one has to replace %H by something to have the longname of the workbook instead of its shortname. But by what?

Thank you very much for your help!
SeanMao Posted - 05/04/2016 : 02:11:47 AM
If you want to use worksheet long name, simply replace this line:

string temp$ = wks.name$;

with

string temp$ = wks.longname$;

Regards!

Sean


quote:
Originally posted by YC.Lai

Hello All

Is it possible only use long name as the exported name?

Regards,

YC.Lai

YC.Lai Posted - 05/04/2016 : 01:02:17 AM
Hello All

Is it possible only use long name as the exported name?

Regards,

YC.Lai
SeanMao Posted - 04/27/2016 : 10:30:03 PM
Hi,

Pls try the following code which will export all worksheets in all workbooks with name as "WORKBOOK NAME_ WORKSHEET NAME".


fdlog.openpath(B); // choose directory

doc -e W{   
doc -e LW
{
string temp$ = wks.name$; // Get worksheet name
expASC type:=text path:=%B%H_%(temp$) shortname:=1; 
};
}



Regards!

Sean

OriginLab Tech.
lsurazyn Posted - 04/27/2016 : 06:33:17 AM
Hello,

I would like to refresh this topic as I'm looking for same solution.

My Origin version is : OriginPro 2015(64-bit)
with Windows 7 as an operating system


I tried your code Mike, it is exporting only active worksheet. Is this possible to export: long name, units and commends as well?

Thanks in advance, Lucas.
daliss Posted - 03/22/2006 : 09:38:19 AM
Thans very much.
It works great.
Mike Buess Posted - 03/22/2006 : 08:31:07 AM
Hi William,

This will export all worksheets in the project to the same directory...

fdlog.openpath(B); // choose directory
doc -e W {save -w %H %B%H.txt};


To export only those worksheets in the active project folder replace the -e switch with -ef.

Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000