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
 multiple EXCEL --> ASCII

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
doncev Posted - 07/18/2006 : 04:56:52 AM
Origin Version (Select Help-->About Origin): 7G SR2
Operating System:WinXP

Hello,
I would like to import several Excel datasheets (just one particular let say one named with "data") and export them into ASCII worksheets with the same names. Any idea how to do this?
Thanks.
Jelena
4   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 07/18/2006 : 1:45:12 PM
Hi Jelena,

doc -a names the Origin worksheet after the Excel datasheet which is not necessarily the same as the xls filename so worksheet name conflicts might arise with the last script. Also, the script does not handle multiple datasheets and opens a prompt for each xls file. The following scrpt takes care of all of those problems. Note: naming conflicts are avoided by closing worksheets after their data are exported so the project will be empty on completion.

fdlog.dlgName$="Select Output Folder";
if( fdlog.OpenPath(Z) ) return;
fdlog.dlgName$="Select Excel Files";
fdlog.UseGroup(Excel);
if (fdlog.MultiOpen() == 0/0) return;
doc -e W {win -cd %H}; // close all worksheets
OpenAsExcel = system.excel.openAsExcel;
OpenAsPrompt = system.excel.openAsPrompt;
system.excel.openAsExcel = 0; // always import as Origin worksheet
system.excel.openAsPrompt = 0; // disable prompt
loop (ii, 1, fdlog.MultiOpen.Count)
{
FDlog.get(N, ii, 1); // %N=file name sans extension
FDlog.get(A, ii); // %A=file path\name
doc -a %A; // import Excel file
doc -e W {
save -w %H %Z%N_%H.txt; // save as ASCII
win -cd %H; // close wks
}
}
system.excel.openAsExcel = OpenAsExcel;
system.excel.openAsPrompt = OpenAsPrompt;
del -v OpenAs*;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/18/2006 2:04:12 PM
Mike Buess Posted - 07/18/2006 : 09:16:43 AM
save -w wksname filename;
- or -
save -wh wksname filename; // see wks.export object for formatting options

...This script opens a multiple file selection dialog and imports/exports the selected Excel files.

fdlog.dlgName$="Select Export folder";
%Z=""; // clear path variable
fdlog.OpenPath(Z); // where to export ASCII files
fdlog.dlgName$="Select Excel files";
fdlog.UseGroup(Excel);
// select Excel files
if (fdlog.MultiOpen() != 0/0)
{
loop (ii, 1, fdlog.MultiOpen.Count)
{
FDlog.Get(A, ii); // get iith file name
doc -a %A; // import file
save -w %H %Z%H.txt; // export as ASCII
}
}

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/18/2006 10:42:24 AM
doncev Posted - 07/18/2006 : 09:07:29 AM
I know how to do it if I have a single files but as I have hunderds of files I would like to do it automaticaly. Any idea how to do it?
Thanks.
Jelena
Mike Buess Posted - 07/18/2006 : 08:58:49 AM
Hi Jelena,

Not sure what you mean by ASCII worksheet. You can export to a simple text file (.txt) use File > Export ASCII. (But you can do that directly from Excel with File > Save As, then select a text format.) If you want to save as an Origin worksheet file (.ogw) use File > Save Window As.

...You can also use LabTalk's save command...

save -w wksname filename; // save wksname as an ASCII file
save -i filename.ogw; // save active window as an OGW file

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/18/2006 09:12:09 AM

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