File: String;
The File property determines the path and the name of the data provider file.
Executing the example requires that the file system contains the OpenDocument file D:\Work\data.ods. The file contains a sheet named Sheet1, the fist row contains column headers, the second row and other rows contain data.
Add a link to the Dt system assembly.
Sub UserProc;
Var
OdsProvider: IDtOdsProvider;
Fields: IDtFieldDefinitions;
Field: IDtFieldDefinition;
FieldName: String;
v: Array;
i: Integer;
Begin
OdsProvider := New DtOdsProvider.Create;
OdsProvider.File := "d:\Work\data.ods";
OdsProvider.Sheet := "Sheet1";
OdsProvider.HasHeader := True;
OdsProvider.HeaderRow := 0;
OdsProvider.DataRow := 1;
OdsProvider.Open;
Fields := OdsProvider.Fields;
Debug.WriteLine("Number of fields: " + Fields.Count.ToString);
FieldName := "Field names: ";
// Create a row with field names
For Each Field In Fields Do
FieldName := FieldName + Field.Name + "; "
End For;
Debug.WriteLine(FieldName);
Debug.WriteLine("Data:");
While Not OdsProvider.Eof Do
OdsProvider.Fetch(v);
For i := 0 To v.Length - 1 Do
Debug.Write(v[i] + " ");
End For;
Debug.WriteLine("");
End While;
OdsProvider.Close;
End Sub UserProc;
After executing the example the console window displays the data read from the specified file.
See also: