2.5.4 DataFormat
Description
Setting and getting a column's data format type to one of the supported COLDATAFORMAT types. Setting a column's data format will erase any data in the column unlike the similar action performed from Origin's Column Property dialog.
Syntax
VB: Property Get/Let DataFormat As COLDATAFORMAT
C++: COLDATAFORMAT DataFormat
C#: COLDATAFORMAT DataFormat
Remark
This property is changed in Origin 8 SR2. Previously you needed to set this property and the InternalDataType property (removed in SR2) to set a column's data type. This is now combined with this single property.
Examples
VBA to Send BYTE data to Origin and Get them Back
Sending BYTE (1 byte integer) data to Origin Column, and getting data back
Public Sub SetDataFormat()
Dim app As Origin.ApplicationSI
Dim Wks As Origin.Worksheet
Dim ii As Integer
Dim data As Variant
Dim send(1 To 100) As Byte
For ii = 1 To 100
send(ii) = ii
Next
Set app = New Origin.ApplicationSI
Set Wks = app.FindWorksheet("")
Wks.Columns(0).DataFormat = DF_BYTE
Wks.Columns(0).SetData (send)
data = Wks.Columns(0).GetData(ARRAY1D_NUMERIC, 0, -1)
Range("A1") = data(0)
End Sub
VBA to Send Text Array to Origin and Getting Back
Sending Text array to Origin Column, and getting data back
Public Sub SetDataFormat()
Dim app As Origin.ApplicationSI
Dim Wks As Origin.Worksheet
Dim ii As Integer
Dim data As Variant
Dim send(1 To 100) As String
For ii = 1 To 100
send(ii) = Str (ii)
Next
Set app = New Origin.ApplicationSI
Set Wks = app.FindWorksheet("")
Wks.Columns(1).DataFormat = DF_TEXT
Wks.Columns(1).SetData (send)
data = Wks.Columns(1).GetData(ARRAY1D_VARIANT, 0, -1)
Range("A1") = data(0)
End Sub
C#
Sending BYTE data to Origin Column, and getting data back
Using Origin;
static void SetDataFormat()
{
byte[] send = new byte[100];
for (byte ii = 0; ii < 100; ii++)
{
send[ii] = ii;
}
Origin.ApplicationSI app = new Origin.ApplicationSI();
Worksheet wks = app.FindWorksheet("");
wks.Columns[0].DataFormat = COLDATAFORMAT.DF_BYTE;
wks.Columns[0].SetData(send, 0);
object data = wks.Columns[0].GetData(ARRAYDATAFORMAT.ARRAY1D_NUMERIC, 0, -1, 0);
send = data as byte[];
Console.WriteLine(send[0] + "\n");
}
C#
Sending Text array to Origin Column, and getting data back
Using Origin;
static void SetDataFormat()
{
string[] send = new string[100];
for (int ii = 0; ii < 100; ii++)
{
send[ii] = ii.ToString();
}
Origin.ApplicationSI app = new Origin.ApplicationSI();
Worksheet wks = app.FindWorksheet("");
wks.Columns[1].DataFormat = COLDATAFORMAT.DF_TEXT;
wks.Columns[1].SetData(send, 0);
object data = wks.Columns[0].GetData(ARRAYDATAFORMAT.ARRAY1D_NUMERIC, 0, -1, 0);
send = data as string[];
Console.WriteLine(send[0] + "\n");
}
Version Information
8.0SR2
See Also
SetData
|