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.PeriodStart := DateTime.Parse("01.01.2000");

Params.PeriodEnd := DateTime.Parse("01.01.2008");

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. Only data from 2000 up to 2008 is exported for the time series, which attribute value COUNTRIES equals 512 or 914.

See also:

IExportRequestInstance