See the example of creating and applying conditional formatting to data area.
Executing the example requires that the repository contains a regular report with the REPORT_INTRO identifier with data area on a sheet.
To execute the example, add links to the Metabase, Report, Tab, Drawing system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
DI: IPrxDataIsland;
Prop: IPrxDataIslandProperties;
TabFormat: ITabFormatCondition;
ValFormat: ITabFormatValues;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("REPORT_INTRO").Edit;
Report := MObj As IPrxReport;
DI := Report.DataIslands.Item(0).Edit;
Prop := DI.Properties;
TabFormat := Prop.FormatConditions.Add;
TabFormat.Type := TabConditionType.Values;
ValFormat := TabFormat.Details As ITabFormatValues;
// Three-colored gradient for cell formatting:
ValFormat.Style := TabFormatValuesStyle.ThreeColorScale;
// Set up minimum value:
ValFormat.MinValueType := TabFormatValueType.Lowest;
ValFormat.MinValueColor := GxColor.FromName("Yellow");
// Set up minimum value:
ValFormat.MidValueType := TabFormatValueType.Percent;
ValFormat.MidValue := 50;
ValFormat.MidValueColor := GxColor.FromName("Green");
// Set up maximum value:
ValFormat.MaxValueType := TabFormatValueType.Highest;
ValFormat.MaxValueColor := GxColor.FromName("Blue");
DI.Save;
MObj.Save;
End Sub UserProc;
After executing the example conditional formatting of the cells is determined on the basis of their values: style - three-color gradient. The created conditional formatting will be saved for the current report.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;
Imports Prognoz.Platform.Interop.Drawing;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
Report: IPrxReport;
DI: IPrxDataIsland;
Prop: IPrxDataIslandProperties;
TabFormat: ITabFormatCondition;
ValFormat: ITabFormatValues;
GxColor: GxColorClassClass = New GxColorClassClass();
Begin
MB := Params.Metabase;
MObj := MB.ItemById["REPORT_INTRO"].Edit();
Report := MObj As IPrxReport;
DI := Report.DataIslands.Item[0].Edit();
Prop := DI.Properties;
TabFormat := Prop.FormatConditions.Add();
TabFormat.Type := TabConditionType.tctValues;
ValFormat := TabFormat.Details As ITabFormatValues;
// Three-colored gradient for cell formatting:
ValFormat.Style := TabFormatValuesStyle.tfvsThreeColorScale;
// Set up minimum value:
ValFormat.MinValueType := TabFormatValueType.tfvtLowest;
ValFormat.MinValueColor := GxColor.FromName("Yellow");
// Set up minimum value:
ValFormat.MidValueType := TabFormatValueType.tfvtPercent;
ValFormat.MidValue := 50;
ValFormat.MidValueColor := GxColor.FromName("Green");
// Set up maximum value:
ValFormat.MaxValueType := TabFormatValueType.tfvtHighest;
ValFormat.MaxValueColor := GxColor.FromName("Blue");
DI.Save();
MObj.Save();
End Sub;
See also: