IExportRequestInstance.Export

Syntax

Export;

Description

The Export method exports factors.

Example

Executing the example requires a time series database with the OBJ_RUBRICATOR identifier. The database must include the COUNTRIES attribute.

Sub Main;

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 consumer for exporting 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 := "OBJ_EXPORTREQUEST";

CrInfo.Permanent := True;

CrInfo.Parent := MB.ItemById("OBJ_RUBRICATOR").Bind;

ObjDesc := MB.CreateObject(CrInfo);

Obj := ObjDesc.Edit;

ExportRequestDef := Obj As IExportRequestDefinition;

 

// Export parameters

Params := ExportRequestDef.Exporter;

Params.Rubricator := MB.ItemById("OBJ_RUBRICATOR").Bind As IRubricator;

Params.Consumer := TextConsumer As IDtConsumer;

Binding := Params.Bindings.Add;

Binding.FieldName := "CountryNm";

Binding.DataType := DbDataType.String;

Binding.BindingType := CubeMetaExporterBindingType.Attribute;

Binding.Attribute := "COUNTRIES";

Binding.KeyField := "NAME";

 

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;

 

Params.ByColumns := True;

Params.CalendarLevel := DimCalendarLevel.Year;

Filter := Params.Filters.Add;

Filter.Attribute := "COUNTRIES";

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 Main;

After executing the example the factors are exported to the C:\result.txt file. Data is exported for only the indicators, which COUNTRIES attribute's value is equal to 512 or 914.

See also:

IExportRequestInstance