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 for Programming
 Forum for Origin C
 worksheet creation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Niko1

Germany
Posts

Posted - 07/25/2005 :  06:56:56 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin):
Operating System:

Hello!
I'd like to know if it's possible to create a worksheet thanks to the code builder(precizing the number of columns and their width). In my case, I can't use a template cause the number of columns is not previously defined: I descover it "dynamically" when I run my program...

easwar

USA
1965 Posts

Posted - 07/25/2005 :  09:38:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Here is a code example. Look at the Worksheet and Column class documentation in the Programming->Origin C Language Reference help file for more information.

Easwar
OriginLab


void make_custom_wks()
{
// First create a worksheet page using Origin.OTW template
// Note: you can replace "Origin" with your custom template name
// if you want to start from some custom configuration
WorksheetPage wpg;
wpg.Create("Origin");

// Point to the first layer in the page, which would be
// the worksheet
Worksheet wks = wpg.Layers(0);

// Delete all existing columns in this worksheet
while( wks.DeleteCol(0) );

// Now let us for example add 4 new cols
// with X Y X Y designation and set their widths
int nIndex;
// Col1
nIndex = wks.AddCol("MyCol1");
wks.Columns(nIndex).SetType(OKDATAOBJ_DESIGNATION_X);
wks.Columns(nIndex).SetWidth(10);
// Col2
nIndex = wks.AddCol("MyCol2");
// Default col type is Y so no need to set this one
wks.Columns(nIndex).SetWidth(8);
// Col3
nIndex = wks.AddCol("MyCol3");
wks.Columns(nIndex).SetType(OKDATAOBJ_DESIGNATION_X);
wks.Columns(nIndex).SetWidth(10);
// Col4
nIndex = wks.AddCol("MyCol4");
// Default col type is Y so no need to set this one
wks.Columns(nIndex).SetWidth(20);
// Add label to this last col for example
string strLabel = "This is column 4 \r\nSecond line of Label";
wks.Columns(nIndex).SetLabel(strLabel);
// Turn on label display for the worksheet
wks.ShowLabels();
}




Edited by - easwar on 07/25/2005 09:40:32 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