IDtExcelProviderEx.File

Syntax

File: String;

Description

The File property determines the entire name of the data source file.

Comments

The name of the sheet, on which data is located is determined by the IDtExcelProviderEx.Sheet property.

Example

Executing the example requires the C:\Data.xlsx file. Add a link to the Dt system assembly.

Fragment of the C:\Data.xlsx file for which the example is written

Sub UserProc;
Var
    ExcelProviderEx: IDtExcelProviderEx;
    Fields: IDtFieldDefinitions;
    Field: IDtFieldDefinition;
    namField, Val: String;
    v: Array;
    i: Integer;
    s: double;
    rez:  boolean;
Begin
    ExcelProviderEx := New DtExcelProviderEx.Create;
    ExcelProviderEx.File := "C:\Data.xlsx";
    ExcelProviderEx.Sheet := "Sheet1";
     ExcelProviderEx.HasHeader := True;
    ExcelProviderEx.HeaderRow := 0;
    ExcelProviderEx.AutoFillFieldsMode :=  DtAutoFillFieldsMode.DataRow;
    ExcelProviderEx.TypeGuessRows := 5;

    ExcelProviderEx.Format := "XLSX";
    ExcelProviderEx.DataRow := 1;
    ExcelProviderEx.Open;
    Fields := ExcelProviderEx.Fields;
    Debug.WriteLine("Fileds number: " + Fields.Count.ToString);
    namField := "Fields names: ";
    // Form a row with fields name
    For Each Field In Fields Do
        namField := namField + Field.Name + "; "
    End For;
    Debug.WriteLine(namField);
    Debug.WriteLine("Data:");
    While Not ExcelProviderEx.Eof Do

        Val := "";
        ExcelProviderEx.Fetch(v);
        // Form row with data
        For i := 0 To v.Length - 1 Do
            rez := CultureInfo.Current.TryParseDouble(v[i], s);
            If Not rez Then
                val := val + v[i] + "; ";
            Else
                val := val + s.ToString + "; ";

            End If;
        End For;
        Debug.WriteLine(val);
    End While;
    ExcelProviderEx.Close;
End Sub UserProc;

After executing the example in the console window data, read from file C:\Data.xlsx, is displayed.

See also:

IDtExcelProviderEx