Add(Type: EaxDataAreaSliceType): IEaxDataAreaSlice;
Type. Data slice type.
The Add method creates analytical data area slice.
To clear collection of analytical data area slices, use IEaxDataAreaSlices.Clear.
To get type of analytical data area slice, use IEaxDataAreaSlice.Type.
Executing the example requires that the repository contains a regular report with the REPORT identifier. A data source containing dimensions with the CALENDAR and COUNTRY identifier is added to the report. Link the Dimensions, Drawing, Express, System, Metabase, Pivot, Report system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Report: IPrxReport;
DA: IEaxDataArea;
Slice: IEaxDataAreaSlice;
Pivot: IPivot;
DimSS: IDimSelectionSet;
DimS: IDimSelection;
DimInst: IDimInstance;
View: IEaxGrid;
Rect: IGxRect;
ViewSets: IEaxGridViewSettings;
T_Header, L_Header: IDataAreaHeaderSettingsBase;
Begin
//Repository access
MB := MetabaseClass.Active;
//Regular report
Report := MB.ItemById("REPORT").Edit As IPrxReport;
// Get data area
DA := Report.DataArea;
// Add data slice
Slice := DA.Slices.Add(EaxDataAreaSliceType.Pivot);
Slice.CreateSource;
Slice.Execute;
// Get data table
Pivot := (Slice As IEaxDataAreaPivotSlice).Pivot;
// Place data source in table
Pivot.DataSource := Report.DataSources.Item(0).DataSource;
//Arrangement of dimensions and setting of selection
Pivot.BeginSelectionUpdate;
DimSS := Pivot.Selection;
For Each DimS In DimSS Do
DimInst := DimS.Dimension;
If DimInst.Ident = "COUNTRY" Then
Pivot.LeftHeader.AddDim(DimInst);
//Select two first elements
DimS.SelectElement(0, False);
DimS.SelectElement(1, False);
Elseif DimInst.Ident = "CALENDAR" Then
Pivot.TopHeader.AddDim(DimInst);
//Select elements of the level where the first element is placed
DimS.SelectSiblings(0);
Else
Pivot.FixedHeader.AddDim(DimInst);
//Select the first element
DimS.SelectElement(0, False);
End If;
End For;
Pivot.EndSelectionUpdate;
//Table data view
View := Slice.Views.AddByType(EaxObjectType.Grid) As IEaxGrid;
View.Pivot := Pivot;
View.TabSheet := (Report.ActiveSheet As IPrxTable).TabSheet;
Rect := New GxRect.Create(0, 0, 0, 0);
View.OutputRect := Rect;
//Set insert methods
ViewSets := View.ViewSettings;
T_Header := Pivot.TopHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings(T_Header) As IEaxGridHeaderSettings).Behaviour := EaxGridHeaderBehaviour.Insert;
L_Header := Pivot.LeftHeader As IDataAreaHeaderSettingsBase;
(ViewSets.GetViewSettings(L_Header) As IEaxGridHeaderSettings).Behaviour := EaxGridHeaderBehaviour.Insert;
//Save changes
Report.MetabaseObject.Save;
End Sub UserProc;
On executing the example a new data slice is created in the regular report. A data area is added and placed on report's active sheet.
See also: