2.1.19 GetWorksheet
Description
The GetWorksheet method transfers data from specified Origin worksheet.
Syntax
VB: Function GetWorksheet(Name As ByVal String, [ r1 As ByVal Object ], [ c1 As ByVal Object ], [ r2 As ByVal Object ], [ c2 As ByVal Object ], [ format As ByVal Object ] ) As Object
C++: _variant_t GetWorksheet(LPCSTR Name, _variant_t r1, _variant_t c1, _variant_t r2, _variant_t c2, _variant_t format )
C#: var GetWorksheet(string Name, var r1, var c1, var r2, var c2, var format )
Parameters
- Name
- Name of Origin worksheet containing data.
- r1
- Starting (zero based) row index to get data from. This is optional argument, defaults to 0.
- c1
- Starting (zero based) column index to get data from. This is optional argument, defaults to 0.
- r2
- Ending (zero based) row index to get data from. This is optional argument, defaults to -1 (to the rest of worksheet).
- c2
- Ending (zero based) column index to get data from. This is optional argument, defaults to -1 (to the rest of worksheet).
- format
- one of the ARRAYDATAFORMAT enumeration, please use only the 2D ones. For example ARRAY2D_NUMERIC.
Return
Array as a variant. Actual array type is dependent on the format argument.
Remark
The Worksheet level GetData and the Application level GetWorksheet are going through the same code. This method is slower than the Column object GetData but it has the flexibility of getting a block of data from multiple columns.
Examples
VBA
Public Sub GetWorksheet()
Dim app As Origin.ApplicationSI
Dim data As Variant
Set app = New Origin.ApplicationSI
data = app.GetWorksheet("[Book1]Sheet1", 0, 0, -1, -1, ARRAY2D_VARIANT)
If data Is Nothing Then
MsgBox ("Failed to get worksheet")
Else
MsgBox ("get worksheet successfully")
Range("A1") = data(0, 0)
End If
End Sub
C#
static void GetWorksheet()
{
Origin.ApplicationSI app = new Origin.ApplicationSI();
object wksdata = app.GetWorksheet("[Book1]Sheet1", 0, 0, 3, 5, ARRAYDATAFORMAT.ARRAY2D_VARIANT);
if (wksdata == null)
{
Console.WriteLine("Failed to get worksheet");
}
else
{
Console.WriteLine("get worksheet successfully\n");
// You can cast wksdata as double[,] or byte[,] etc. for the data array of different types
object[,] data = wksdata as object[,];
Console.WriteLine("data[1,1]=" + data[1,1] + "\n");
}
Console.ReadLine();
}
Python
import OriginExt as O
app = O.Application(); app.Visible = app.MAINWND_SHOW
pageName = app.CreatePage(app.OPT_WORKSHEET)
testData = [[5,87,90], [3.14, 24.6, 68.09]]
app.PutWorksheet(pageName, testData)
outputData = app.GetWorksheet(pageName)
print(outputData)
Version Information
8.0SR2
See Also
PutWorksheet | Worksheet.SetData | Worksheet.GetData
| Column.SetData | Column.GetData
|