Executing the example requires the following objects in the repository:
A folder with the WORKBOOKS identifier to which a created workbook is saved.
A time series database with the TSDB identifier using which a workbook is created. The database must contain the series with the 45718 key.
An express report or a workbook with the OBJ123 identifier from which a sheet is added to the created workbook.
Add links to the following system assemblies:
Cubes.
Express.
Laner.
Metabase (only for Fore).
Sub UserProc;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Exp: IEaxAnalyzer;
Source: IMetabaseObjectDescriptor;
WB: ILaner;
FactD: IRubricatorFactData;
RubFactor : IRubricatorFactor;
Series: ILanerSeries;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_WORKBOOK;
CrInfo.Id := MB.GenerateId("NewWorkbook");
CrInfo.Name := "A new workbook";
CrInfo.Parent := MB.ItemById("WORKBOOKS");
//Create the repository object "Workbook"
MObj := MB.CreateObject(CrInfo).Edit;
Exp := MObj As IEaxAnalyzer;
//Determine a source for the workbook
Source := MB.ItemById("TSDB");
//Add a second sheet from express report or workbook with the defined identifier to the workbook
Exp.Sheets.Add(MB.ItemById("OBJ123").Bind As IEaxAnalyzer);
WB := Exp.Laner;
WB.RubricatorInstance := Source.Open(Null) As IRubricatorInstance;
//Return the factor with the defined key from the time series database
FactD := WB.RubricatorInstance.GetFactData(45718);
RubFactor := FactD.Factor;
Series:= WB.Series;
//Add a series from the time series database to the workbook active sheet
Series.AddCalculateSerieAsSource(RubFactor);
//Save the created repository object
MObj.Save;
End Sub UserProc;
After executing the example the folder with the WORKBOOK identifier will contain a workbook named "A New Workbook" having the time series database with the TSDB identifier as a source. A second sheet from express report or workbook with the OBJ123 identifier is added to the workbook. The series with the 45718 key is added to the active sheet of the workbook from the workbook source.
The defined procedure is the Main entry point in the Program module of the .NET assembly. The Express, Metabase, Laner, Cubes assemblies must be imported to this module from the Prognoz.Platform.Interop system assembly.
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Exp: IEaxAnalyzer;
Source: IMetabaseObjectDescriptor;
WB: ILaner;
FactD: IRubricatorFactData;
RubFactor : IRubricatorFactor;
Series: ILanerSeries;
Begin
MB := Params.Metabase;
CrInfo := MB.CreateCreateInfo();
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_WORKBOOK As integer;
CrInfo.Id := MB.GenerateId("NewWorkbook");
CrInfo.Name := "A new workbook";
CrInfo.Parent := MB.ItemById["WORKBOOKS"];
//Create the repository object "Workbook"
MObj := MB.CreateObject(CrInfo).Edit();
Exp := MObj As IEaxAnalyzer;
Source := Exp.DataSourceDescriptor;
//Determine a workbook source
Source := MB.ItemById["TSDB"];
//Add a second sheet from express report or workbook with the defined identifier to the workbook
Exp.Sheets.Add(MB.ItemById["OBJ123"].Bind() As IEaxAnalyzer);
WB := Exp.Laner;
WB.RubricatorInstance := Source.Open(Null) As IRubricatorInstance;
//Return the factor with the defined key from the time series database
FactD := WB.RubricatorInstance.GetFactData(45718);
RubFactor := FactD.Factor;
Series:= WB.Series;
//Add a series from the time series database to the workbook active sheet
Series.AddCalculateSerieAsSource(RubFactor);
//Save the created repository object
MObj.Save();
End Sub;
The result of example execution matches with that of the Fore example.
See also: