How to Change the Color of a Cell in DIAdem Table with Scripting

Updated Oct 8, 2019

Reported In

Software

  • DIAdem

Issue Details

I am trying to change the text color of a cell of a 2D table in a report. In older version of DIAdem, I was able to use the D2TabNumColor variable, however, this command is now obsolete. How can I achieve this functionality with a newer version of DIAdem?

Solution

To obtain this type of functionality the object-oriented interface in DIAdem REPORT must be used. You can use the event OnDrawingCell for 2DTable Colums Settings.

The first example script in this help page is the script that you will run. It will create a table in a report and then call the user command script (the second example script) on the referenced column of the table. The user command script will then access each cell of the table individually and make the changes. You can modify this user command script as below to just change the color of a cell:

Sub MyOnDrawingCell(Context, Cell)
  If (Context.Table.Name = "My2DTable") Then
    If (Cell.Value > 0.06) Then
     Cell.Font.Color.SetPredefinedColor(2)
    End If
  End If
End Sub