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