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, based on which a workbook is created. The database must contain a 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.
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 Workbook repository object
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 specified 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 indicator with the specified 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 contains a workbook named "New Workbook" having the time series database with the TSDB identifier as a source. The second sheet from of the express report/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.
See also: