Bindings: ICubeMetaExporterBindings;
The Bindings property determines bindings of attributes of the time series database with data consumer fields.
To determine the exported time series database, use the IExportRequestParams.Rubricator property.
Executing the example requires a time series database with the TSDB identifier. This database must contain an attribute of the time series with the COUNTRY identifier that refers to a dictionary.
Add links to the Cubes, Dal, Dimensions, Dt, Metabase system assemblies.
Sub UserProc;
Var
TextConsumer: IDtTextConsumer;
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
ObjDesc: IMetabaseObjectDescriptor;
Obj: IMetabaseObject;
ExportRequestDef: IExportRequestDefinition;
Params: IExportRequestParams;
Binding: ICubeMetaExporterBinding;
Filter: ICubeMetaExporterFilter;
FilterValues: Array;
ExportRequestInst: IExportRequestInstance;
Begin
// Data successor to export to the textual format
TextConsumer := New DtTextConsumer.Create;
TextConsumer.File := "C:\result.txt";
TextConsumer.FormatType := DtTextFormatType.Delimited;
TextConsumer.DelimitedColumnDelimiter := ";";
TextConsumer.DelimitedTextQualifier := """";
TextConsumer.Encoding := "WIN";
TextConsumer.WriteHeader := True;
// Export object
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_EXPORTREQUEST;
CrInfo.Id := MB.GenerateId("OBJ_EXPORTREQUEST");
CrInfo.Permanent := True;
CrInfo.Parent := MB.ItemById("TSDB").Bind;
ObjDesc := MB.CreateObject(CrInfo);
Obj := ObjDesc.Edit;
ExportRequestDef := Obj As IExportRequestDefinition;
// Export parameters
Params := ExportRequestDef.Exporter;
Params.Rubricator := MB.ItemById("TSDB").Bind As IRubricator;
Params.Consumer := TextConsumer As IDtConsumer;
Params.ClearBeforeExport := True;
// Binding of COUNTRY attribute
Binding := Params.Bindings.Add;
Binding.FieldName := "CountryNm";
Binding.DataType := DbDataType.String;
Binding.BindingType := CubeMetaExporterBindingType.Attribute;
Binding.Attribute := "COUNTRY";
Binding.KeyField := "NAME";
// Calendar binding
Binding := Params.Bindings.Add;
Binding.FieldName := "Year";
Binding.DataType := DbDataType.String;
Binding.BindingType := CubeMetaExporterBindingType.Calendar;
Binding.DateFormat := "$Year$";
Binding.ValueFieldName := "Value";
Binding.ValueDataType := DbDataType.Float;
// Filtration parameters
Params.ByColumns := True;
Params.CalendarLevel := DimCalendarLevel.Year;
Params.RowCount := 1000;
Filter := Params.Filters.Add;
Filter.Attribute := "COUNTRY";
FilterValues := New Variant[2];
FilterValues[0] := 512;
FilterValues[1] := 914;
Filter.ValuesList := FilterValues;
Obj.Save;
// Export
ExportRequestInst := (ExportRequestDef As IMetabaseObjectDescriptor).OpenWithParam(Null) As IExportRequestInstance;
ExportRequestInst.Export;
End Sub UserProc;
After executing the example the data of the time series will be exported to the C:\result.txt file by the following parameters:
The data of the time series is exported if the value of the COUNTRY attribute is equal to 512 or 914.
Not more than 1000 strings will be exported.
The file consumer is cleared before the export.
See also: