Creating a Workbook with Several Sheets and Adding Data to It

Executing the example requires the following objects in the repository:

Add links to the following system assemblies:

Example

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(NullAs 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.

See also:

Examples | ILaner | ILanerSeries