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
 Automatic graph naming and importing xls data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

DrMorbid

United Kingdom
14 Posts

Posted - 08/19/2014 :  12:53:48 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello Origin users,

would anyone know how I can make Origin automatically change the long names of my graphs to match the filename? Then I export the graphs as jpg and their names are: <long name> <short name> and this ensure each jpg graph has unique naming, but doing this manually is a bit tedious (transistor characterisation, many devices have to be tested).

Also, I always import data from xls files, but is there any way of automatic it as well? At the moment I have to manually choose Import Excel, then load up the appropriate worksheets and copy the data into the previously existsing sheets within Origin (which contain all the necessary formulas for calculating extra parameters from the measured data).

Thank you very much for help!

greg

USA
1378 Posts

Posted - 08/19/2014 :  4:57:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You should be able to use templates to solve both problems.

Long Names follow Sheet Names:
Create one of your graphs.
Add a text object with any text anywhere.
Alt+DoubleClick on the text object to open its Programming Control.
Put this script in the box:

page.label$ = %(1,@WS); // The page label is the Long Name

Set the Script, Run After: to "Axes Rescale" and click OK.
Save this graph as a Template with a new name. (File : Save Template As...)

When you going to create a graph, choose Plot : Template Library and pick your saved Template.


Import Excel for automation:
Take one of your "previously existing sheets" with all your calculations.
Insert a new sheet.
The idea is that you will import your Excel data into this empty sheet of your new analysis template. You will need to add some code to a new column in the second sheet (with all the other calculations) which copies the imported Excel data to the correct columns in the second sheet.
The script (in Before Formula Script of Set Values) might look like this:
range ra1 = 1!1; // First column of first sheet
colcopy irng:=ra1 orng:=1; // Copy to first column of this sheet
range ra2 = 1!2; // Second column of first sheet
colcopy irng:=ra2 orng:=2; // Copy to second column of this sheet
etc.
When you are all set, make the first sheet active and choose File : Save Workbook as Analysis Template and give it an easy name and put it in your User Files Folder.

Here's a batch import script:
dlgfile gr:=Excel mu:=1;
loop(ii,1,fname.GetNumTokens(CRLF))
{
file$ = fname.gettoken(ii,CRLF)$;
doc -o %YMyAnalysisTemplate.ogw; // or your custom path
impexcel
fname:=file$
impmode:=sheet
sheet:=1
options.names.AutoNames:=1;
}

Edited by - greg on 08/20/2014 08:50:56 AM
Go to Top of Page

DrMorbid

United Kingdom
14 Posts

Posted - 08/23/2014 :  05:56:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much for your help and introducing me to scripting in Origin! Most of the things I wanted work, just somehow cannot add a new axis onto an existing graph and adding another curve.

Edited by - DrMorbid on 08/24/2014 5:25:10 PM
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