2.42.12 Labels


Description

Construct worksheet label region using Label Row Characters.

Syntax

VB: Sub Labels(pattern As ByVal String ) As void
C++: void Labels(LPCSTR pattern )
C#: void Labels(string pattern )

Parameters

pattern
A string of patterns, which can be specified by assembling Label Row Characters

Return

Remark

The following new prefix support(+, -, *) were added in Origin 8 SR2, They will indicate the character list for Insert/Add/Delete, as otherwise the list will do complete replacement of current settings:

  • + Insert the list to the top
  • - to remove any from list
  • * to append the list to the bottom

For example:

wks.labels(-U): to remove Units
wks.labels(+ES): to insert Sample Rate and Sparklines to the top
wks.labels(*U): to append Units to the bottom

Examples

VBA

Connect to the running Origin(please make sure that there are two sheets in Book1). We will set some labels in the two sheets to visible, and set content to these labels. You will see result in Origin.

Public Sub setLabelVisible()
    Dim app As Origin.ApplicationSI
    Dim Wks1 As Origin.Worksheet
    Dim Wks2 As Origin.Worksheet
    Dim Data(1 To 100) As Double
    Dim bRet As Boolean
    Dim ii As Integer
    For ii = 1 To 100
        Data(ii) = ii * 0.375 + 274
    Next
 
    Set app = New Origin.ApplicationSI
    Set Wks1 = app.FindWorksheet("[Book1]Sheet1")
    Set Wks2 = app.FindWorksheet("[Book1]Sheet2")
 
    'Set labels to visible
    Wks1.Labels ("LSE")      'Set "LongName", "Spark line" and "Even Sampling" labels of Sheet1 are visible
    Wks2.Labels ("UC")      'Set "Units", "Comments" labels of Sheet2 are visible
    
    'Set Column's LongName
    Wks1.Columns(0).LongName = "Temperature"     'Set LongName of the first column on Sheet1
    Wks2.Columns(0).Units = "kPa"                'Set Units of the first column on Sheet2
    Wks2.Columns(0).Comments = "example"         'Set Comments of the first column on Sheet2
 
    'Set even sampling
    bRet = Wks1.Columns(0).SetEvenSampling(0, 20)
    
    'Send data to the column
    Wks1.Columns(0).SetData (Data)
    Wks2.Columns(0).SetData (Data)
 
End Sub

C#

This example loads the Combining Line and Contour Plots project installed with Origin 8. After loading the project it gets the Book1 worksheet and sets it's visible labels to Long Names only and sets the number of columns to 3.

using System;
using Origin;

static void SetWorksheetLabels()
{
    ApplicationSI app = new ApplicationSI();
    app.Load(app.Path(Origin.APPPATH_TYPES.APPPATH_PROGRAM) + "Samples\\3D Graphing\\Combining Line and Contour Plots.opj", true);

    Worksheet wks = app.FindWorksheet("Book1");
    wks.Labels("L"); // Show Long Names only
    wks.Cols = 3; // Set the number of columns to 3

    Console.WriteLine("\nPress a key to exit.");
    Console.ReadKey();
}

LabVIEW

The following LabVIEW Block Diagram shows how to set a worksheet's number of columns to 3 and configure to show only the column long names.

COM LV Wks Labels.gif

Version Information

8.0SR2

See Also

LabelVisible | Column.Name | Column.LongName | Column.Type | Column.Units | Column.Comments