Query: String;
The Query property determines Excel sheets query. Imported data is selected by means of the query.
As a value of the property the following values can be selected:
SQL query to be used to select data. Example: Select * From [Sheet1$].
Sheet names. Example: Sheet1.
NOTE. The sheet name must not contain the characters "[","]" and "*".
Executing the example requires an ETL task with the Etl identifier in repository and Excel file named Data.xls in the disk C root directory.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlProvider: IEtlPlainDataProvider;
ExcelProvider: IDtExcelProvider;
WxProvider: IWxRectangle;
WxETLProvider: IWxETLObject;
Begin
MB := MetabaseClass.Active;
//Searching ETL task. Repository object with the ETL identifier
MObj := MB.ItemById("Etl").Edit;
EtlTask := MObj As IEtlTask;
//Start provider creation
//Create the object "Import from Excel"
EtlProvider := EtlTask.Create(EtlObjectType.PlainDataExcelProvider) As IEtlPlainDataProvider;
EtlProvider := EtlProvider.Edit;
EtlProvider.Id := "Excel_Provider";
EtlProvider.Name := "Import from Excel";
EtlProvider.Description := "Import from Excel";
//Set up data provider
ExcelProvider := EtlProvider.Provider As IDtExcelProvider;
ExcelProvider.DriverVersion := "Excel 8.0";
ExcelProvider.File := "c:\Data.xls";
ExcelProvider.HasHeader := True;
ExcelProvider.ImexMode := DtExcelImexMode.Import;
ExcelProvider.Query := "Select * From [Sheet1$]";
EtlProvider.FillDefault;
//Save provider
EtlProvider.Save;
//End of provider creation
//Start visual object creation
WxProvider := EtlTask.Workspace.CreateRectangle;
WxETLProvider := New WxETLObject.Create;
WxETLProvider.ETLObject := EtlProvider;
WxProvider.Style.TextPosition := WxTextPosition.Bottom;
WxProvider.Style.PictureMarginTop := -10;
WxProvider.PinPosition := New GxPointF.Create(50, 50);
WxProvider.Extension := WxETLProvider As IWxShapeExtension;
//End of visual object creation
//Save ETL task
MObj.Save;
End Sub UserProc;
After executing the example the Import From Excel object is created in the ETL task . This source imports all data from the Data.xls Excel file. Sheet name is Sheet1. The Excel 8.0 drivers are used for connection. Field names are imported from the first file row. Fields that contain data of different types are imported entirely.
See also: