Table Style Setting

To set up table style, the ITabTableStyles interface is used.

The example of table style modification in regular report with the REPORT_TAB identifier is given. The report contains analytical data area.

As a result the table looks as follows:

Example

Executing the example requires to add links to the Drawing, Metabase, Report, Tab system assemblies.

Sub TableStyle;
Var
    mb: IMetabase;
    Report: IPrxReport;
    Table: ITabSheet;
    Styles: ITabTableStyles;
    TableStyle: ITabTableStyle;
    Style: ITabCellStyle;
    Color: IGxColor;
    TStripe: ITabTableStripe;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get regular report
    Report := mb.ItemById("REPORT_TAB").Edit As IPrxReport;
    // Get table
    Table := (Report.ActiveSheet As IPrxTable).TabSheet;
    // Get table styles
    Styles := Table.TableStyles;
    // Clear existing styles
    Styles.Clear;
    // Add new table style
    TableStyle := Styles.Add;
    // Set a range for which the table style is used
    TableStyle.Range := Table.Regions.Item(0).Range;
    // Set style name
    TableStyle.Name := "Style for the table is "Light Blue'";
    // Create a new style
    Style := New TabCellStyle.Create;
    Color := New GxColor.CreateRGB(200238253);
    Style.BackgroundBrush := New GxSolidBrush.Create(Color);
    // Set created style for the second line formatting of table rows
    TStripe := TableStyle.RowSecondStripe;
    TStripe.Style := Style;
    TStripe.Width := 1;
    // Change created style
    Color := New GxColor.CreateRGB(98200255);
    Style.BackgroundBrush := New GxSolidBrush.Create(Color);
    // Set updated style to format the first row and the first column 
    TStripe := TableStyle.HeaderColumnStripe;
    TStripe.Style := Style;
    TStripe.Width := 1;
    TStripe := TableStyle.HeaderRowStripe;
    TStripe.Style := Style;
    TStripe.Width := 1;
    // Save changes
    (Report As IMetabaseObject).Save;
End Sub TableStyle;

See also:

General Programming Principles Using the Tab Assembly