2.42.16 NewDataRange
Description
Creating a DataRange object.
Syntax
VB: Function NewDataRange([ r1 As ByVal Object ], [ c1 As ByVal Object ], [ r2 As ByVal Object ], [ c2 As ByVal Object ] ) As DataRange
C++: DataRange NewDataRange(_variant_t r1, _variant_t c1, _variant_t r2, _variant_t c2 )
C#: DataRange NewDataRange(var r1, var c1, var r2, var c2 )
Parameters
- r1
- --
- c1
- --
- r2
- --
- c2
- --
Return
Remark
Examples
VBA
Connect to the running Origin. Set a new data range in the active worksheet, and then send data to it. You can see the result in Origin.
Public Sub NewDataRange()
Dim app As Origin.ApplicationSI
Dim Wks As Origin.Worksheet
Dim range As Origin.DataRange
Dim Data1(1 To 100) As Double
Dim Data2(1 To 100) As Double
Dim ii As Integer
For ii = 1 To 100
Data1(ii) = ii * 0.125
Data2(ii) = ii + 3.75
Next
Set app = New Origin.ApplicationSI
Set Wks = app.FindWorksheet("")
'Set the new range, which starts from row 0 and col 0
Set range = Wks.NewDataRange(0, 0)
range.SetData (Data1) 'Send 1D data array to this range
'Set another new range, which starts from row 0 and col 1
Set range = Wks.NewDataRange(0, 1)
range.SetData (Data2)
End Sub
C#
using Origin;
static void NewDataRange()
{
object Default = System.Type.Missing;
double[] Data1 = new double[100];
double[] Data2 = new double[100];
for (int ii = 0; ii < 100; ii++)
{
Data1[ii] = ii * 0.125;
Data2[ii] = ii + 3.75;
}
Origin.ApplicationSI app = new Origin.ApplicationSI();
Worksheet wks = app.FindWorksheet("");
DataRange range = wks.NewDataRange(0, 0, 0, -1, -1);
range.SetData(Data1, Default, Default);
}
Version Information
8.0SR2
See Also
DataRange.SetData
|