FormatType: DtTextFormatType;
The FormatType property determines file structure format, according to which data is exported. By default format with delimiters is used.
Executing the example requires that the repository contains an ETL task with the Etl identifier.
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
TextConsumer: IDtTextConsumer;
Fields: IDtFieldDefinitions;
Field: IDtTextConsumerField;
WxConsumer: IWxRectangle;
WxETLConsumer: IWxETLObject;
Begin
MB := MetabaseClass.Active;
//ETL task search. Repository object with the ETL identifier
MObj := MB.ItemById("Etl").Edit;
EtlTask := MObj As IEtlTask;
//Start of the provider creation
//The Export To Text object creation
EtlConsumer := EtlTask.Create(EtlObjectType.PlainDataTextConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit;
EtlConsumer.Id := "Text_Consumer";
EtlConsumer.Name := "Export to text";
EtlConsumer.Description := "Export to text";
//Set up data provider
TextConsumer := EtlConsumer.Consumer As IDtTextConsumer;
TextConsumer.File := "c:\Data_Out.txt";
TextConsumer.FormatType := DtTextFormatType.Fixed;
TextConsumer.RowDelimiter := #13 + #10; //Carriage return + row transfer
TextConsumer.WriteHeader := True;
//Fixed length fields setting
Fields := TextConsumer.Fields;
Field := Fields.Add As IDtTextConsumerField;
Field.Name := "Field0";
Field.DataType := DbDataType.String;
Field.FixedLength := 15;
Field := Fields.Add As IDtTextConsumerField;
Field.Name := "Field1";
Field.DataType := DbDataType.String;
Field.FixedLength := 15;
Field := Fields.Add As IDtTextConsumerField;
Field.Name := "Field2";
Field.DataType := DbDataType.String;
Field.FixedLength := 15;
EtlConsumer.FillDefault;
//Save provider
EtlConsumer.Save;
//End of provider creation
//Start of visual object creation
WxConsumer := EtlTask.Workspace.CreateRectangle;
WxETLConsumer := New WxETLObject.Create;
WxETLConsumer.ETLObject := EtlConsumer;
WxConsumer.Style.TextPosition := WxTextPosition.Bottom;
WxConsumer.Style.PictureMarginTop := -10;
WxConsumer.PinPosition := New GxPointF.Create(50, 50);
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
//End of visual object creation
//Save Etl task
MObj.Save;
End Sub Main;
After executing the example a new data consumer, that exports data in text file, is created. During export the Carriage return+Row transfer combination is used as a row delimiter, fields structure is fixed. For one field 15 positions are allowed. Field names are exported in the first file row. If the file does not exist it is created.
See also: