2.1.15 FindMatrixSheet


Description

Find a matrix sheet by name.

Syntax

VB: Function FindMatrixSheet(Name As ByVal String ) As MatrixSheet
C++: MatrixSheet FindMatrixSheet(LPCSTR Name )
C#: MatrixSheet FindMatrixSheet(string Name )

Parameters

Name
The range string of the Origin matrix sheet to be found. The range string contains the workbook name between square brackets followed by the sheet name:
[<bookName>]<sheetName>
The following special notations are also supported:
  1. Empty string -- this means the active sheet from the active book
  2. Book name only -- like "Book1", will get the active sheet from named book
  3. Sheet name only with ! at the end -- like "Sheet2!", will get the named sheet from the active book

Return

If the named matrix sheet is found then an Origin MatrixSheet is returned.

Remark

Examples

VBA

Private Sub SetMatrixSheetDimensions(sheetName As String, numRows As Integer, numCols As Integer)
    Dim app As Origin.ApplicationSI
    Set app = New Origin.ApplicationSI

    Dim msheet As Origin.MatrixSheet
    Set msheet = app.FindMatrixSheet(sheetName)
    If msheet Is Nothing Then
        MsgBox ("Failed to find matrix sheet")
        Exit Sub
    End If

    ' Put current dimensions in Excel sheet cells A1 and B1
    Range("A1") = msheet.Rows ' put number of rows in Excel cell A1
    Range("B1") = msheet.Cols ' put number of columns in Excel cell B1

    msheet.Rows = numRows
    msheet.Cols = numCols
    
    ' Put new dimensions in Excel sheet cells A2 and B2
    Range("A2") = msheet.Rows ' put number of rows in Excel cell A1
    Range("B2") = msheet.Cols ' put number of columns in Excel cell B1
End Sub

C#

using Origin; // allow using MatrixSheet without having to write Origin.MatrixSheet

static void SetMatrixSheetDimensions(string strSheetName, int nRows, int nCols)
{
    ApplicationSI app = new Origin.ApplicationSI();

    MatrixSheet msheet = app.FindMatrixSheet(strSheetName);
    if( msheet == null )
    {
        Console.WriteLine("Matrix sheet " + strSheetName + " not found.");
        return;
    }
    Console.WriteLine("Current dimensions of " + msheet.Name + " are " + msheet.Rows + " rows by " + msheet.Cols + " columns.");

    msheet.Rows = nRows;
    msheet.Cols = nCols;
    Console.WriteLine("New dimensions of " + msheet.Name + " are " + msheet.Rows + " rows by " + msheet.Cols + " columns.");

    Console.ReadKey();
}

Python

import OriginExt as O
app = O.Application(); app.Visible = app.MAINWND_SHOW
pageName = app.CreatePage(app.OPT_MATRIX)
layer = app.FindMatrixSheet(pageName)
print(layer.Name)

Version Information

8.0SR2

See Also

FindWorksheet