Find a worksheet by name.
VB: Function FindWorksheet(Name As ByVal String ) As Worksheet
C++: Worksheet FindWorksheet(LPCSTR Name )
C#: Worksheet FindWorksheet(string Name )
[<bookName>]<sheetName>
If the named worksheet is found then an Origin Worksheet is returned.
Private Sub OutputWorksheetColumnNames(sheetName As String) Dim app As Origin.ApplicationSI Set app = New Origin.ApplicationSI Dim wks As Origin.Worksheet Set wks = app.FindWorksheet("[Book1]Sheet1") If wks Is Nothing Then MsgBox ("Failed to find worksheet") Exit Sub End If Range("A1") = wks.Cols ' put number of columns in Excel cell A1 Dim i As Long Dim col As Origin.Column Dim name As String For i = 1 To wks.Cols Set col = wks.Columns.Item(i - 1) If col.LongName = "" Then name = col.name ' use column short name Else name = col.LongName ' use column long name End If Range("B" & i) = name ' put name in Excel column B row i Next i End Sub
using Origin; // allow using Column, Worksheet, etc. without having to write Origin.Column static void OutputActiveWorksheetColumnNames() { ApplicationSI app = new Origin.ApplicationSI(); Worksheet wks = app.FindWorksheet(""); // pass empty string for active sheet if (wks == null) { Console.WriteLine("Failed to get active worksheet."); return; } Console.WriteLine("Active worksheet name is " + wks.Name); Column col; for( int i = 0; i < wks.Columns.Count; i++ ) { col = wks.Columns[i]; if (col == null) Console.WriteLine("Failed to get column " + i); else Console.WriteLine("Column " + i + " name is " + col.Name); } Console.ReadKey(); }
import OriginExt as O app = O.Application(); app.Visible = app.MAINWND_SHOW pageName = app.CreatePage(app.OPT_WORKSHEET) layer = app.FindWorksheet(pageName) print(layer.Name)
8.0SR2
FindMatrixSheet