Opening Workbook, Changing Data and Saving Changes

Executing the example requires that the repository contains a workbook with the OBJ123 identifier in which data is changed and saved.

Add links to the following system assemblies:

Fore Example

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    Exp: IEaxAnalyzer;
    WB: ILaner;
    Table: ILanerTable;
    i, j: Integer;
Begin
    MB := MetabaseClass.Active;
    //Open a workbook to edit
    MObj := MB.ItemById("OBJ123").Edit;
    Exp := MObj As IEaxAnalyzer;
    WB := Exp.Laner;
    //Get a workbook table
    Table := WB.Execute;
    //Enable table editing
    If Not Table.IsEditing Then
        Table.Edit;
    End If;
    //Assign random values from 0 to 100 to all available table cells
    For i := 0 To Table.RowCount - 1 Do
    For j := 0 To Table.ColumnCount - 1 Do
    If Table.IsEditableCell(i, j) Then
    Table.Cell(i, j) := Math.RandBetween(0100);
    End If;
    End For;
    End For;
    //Save changes
    Table.Post;
    Table.Update;
    MObj.Save;
End Sub UserProc;

After executing the example the workbook with the defined identifier is opened to edit. Data in the workbook table is replaced with the random values from 0 to 100.

Fore.NET Example

The defined procedure is the Main entry point in the Program module of the .NET assembly. The Express, Metabase, Laner, MathFin assemblies must be imported to this module from the Prognoz.Platform.Interop system assembly.

Public Shared Sub Main(Params: StartParams);

Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    Exp: IEaxAnalyzer;
    WB: ILaner;
   Table: ILanerTable;
    i, j: Integer;
    m: Prognoz.Platform.Interop.MathFin.MathClass;
Begin
    MB := Params.Metabase;
    //Open a workbook to edit
    MObj := MB.ItemById["OBJ123"].Edit();
    Exp := MObj As IEaxAnalyzer;
    WB := Exp.Laner;
   //Get a workbook table
    Table := WB.Execute();
    //Enable table editing
    If Not Table.IsEditing Then
        Table.Edit();
    End If;
    //Assign random values from 0 to 100 to all available table cells
    For i := 0 To Table.RowCount - 1 Do
    For j := 0 To Table.ColumnCount - 1 Do
    If Table.IsEditableCell[i, j] Then
        m := New Prognoz.Platform.Interop.MathFin.MathClass.Create();
        Table.Cell[i, j] := m.RandBetween(0100);
    End If;
    End For;
    End For;
    //Save changes
    Table.Post();
    Table.Update();
    MObj.Save();
End Sub;

The result of example execution matches with that of the Fore example.

See also:

Examples | ILaner | ILanerTable