Add: IPrxFormulaIsland;
The Add method adds formula areas.
Executing the example requires that the repository contains a regular report with the REPORT identifier that contains integer numbers in the A0, B0 cells.
Add links to the Metabase, Report and Tab system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
FormulaIs: IPrxFormulaIslands;
Formula: IPrxFormulaIsland;
FSheet: IPrxSheet;
FSheetTab: IPrxTable;
Table: ITabSheet;
Begin
MB := MetabaseClass.Active;
// Get regular report
MObj := MB.ItemById("REPORT").Edit;
Report := MObj As IPrxReport;
FSheet := Report.ActiveSheet;
// Get formula area
FormulaIs := Report.FormulaIslands;
// Add a new formula area
Formula := FormulaIs.Add;
Formula.Sheet := FSheet;
FSheetTab := FSheet As IPrxTable;
Table := FSheetTab.TabSheet;
// Set basic cell
Formula.Origin := Table.Cell(0,2);
// Set cell range
Formula.Range := Table.Cells(0,2,5,7);
// Set formula
Formula.Formula := "A0+B0";
// Save changes in formula area
Formula.Save;
// Calculate formula area
Formula.Recalc;
// Save changes in report
MObj.Save;
End Sub UserProc;
After executing the example a formula area is created on the active sheet of the regular report. Base cell C0, cell range C0:H5, formula A0+B0.
See also: