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
 Copy from XL to Origin Worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

shepman

USA
1 Posts

Posted - 07/30/2002 :  1:04:59 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I want to copy columns of data from an XL worksheet to an Origin datasheet so that the first row of the copied XL is pasted as the column headers of the Origin datasheet. I know that this can be done with import ASCII, but that takes too long, and I am lazy.

shepman

easwar

USA
1964 Posts

Posted - 07/30/2002 :  2:08:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

If you have ver 7, you can use the following Origin C code to do this:

Compile and link this function. Then cut and paste your data into a worksheet. With the worksheet as the active window, go to Script Window and type:
shiftup
or type
shiftup 1
The first command will take the first row content and rename column names to be those strings
The second command will rename the labels instead of the column names.

Easwar
OriginLab.



void ShiftUp(int iOpt = 0)
{
// Get active page and its name
Page pg = Application.Pages();
string strPageName = pg.GetName();
// Declare workseet object and check validity
Worksheet wks(strPageName);
if(!wks.IsValid())
{
printf("Active page is not a worksheet!\n");
return
}
// Loop thru all columns of worksheet
foreach(Column col in wks.Columns)
{
// Get col index
int iColNum = col.GetIndex();
// Read 1st row of col to string
string strName;
wks.GetCell(0,iColNum, strName);
// Set col name or col label with string
if(iOpt == 0)
col.SetName(strName);
else
col.SetLabel(strName);
}
if(iOpt !=0) wks.ShowLabels();

// Delete first row of worksheet
wks.DeleteRow(0);
}


Edited by - easwar on 07/30/2002 2:53:33 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