DataSheetRow(SheetName: String): Integer;
SheetName. Sheet name.
The DataSheetRow property determines the index of the first row containing data for the selected sheet.
This property is relevant if the Sheet property contains names of several sheets of the data file.
Executing the example requires that the file system contains the OpenDocument file D:\Work\data.ods. The file contains two sheets named Sheet1 and Sheet2, the first row of each sheet contains column headers, the second row and the 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\;Sheet2";
OdsProvider.HasHeader := True;
OdsProvider.HeaderRow := 0;
OdsProvider.DataSheetRow("Sheet1") := 1;
OdsProvider.DataSheetRow("Sheet2") := 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 a new provider linked to the specified file is created. The values are exported from two sheets starting with selected rows. The obtained data will be displayed in the development environment console.
See also: