Desktop User Guides > Professional > Table scripting > Table presentation > Hiding rows, columns, and cells > Hiding rows and columns
Hiding rows and columns
Sample script file: HideRules.mrs
This example script is based on the Museum XML sample data set. See Running the sample table scripts for more information.
You might want to hide rows or columns in your tables in which all of the values are zero, such as the Not answered row and column in the following table:
This graphic is described in the surrounding text.
To hide a row where all values are zero, you add a hide rule to the table definition, using the AddNew method, as follows:
The default rule specification hides rows where all values in the first cell item in each cell are equal to zero, so you do not need to specify any parameters for the rule. The AddNew method has the following parameters, which you can use to specify more complex rules:
TableName.Rules.AddNew(Type, Target, CellItemRef, Operator, Value)
The first parameter, Type, specifies the rule type. As the default rule type is a hide rule, you do not need to specify this (in the current release, hide rules are the only rule type available). The second parameter, Target, specifies whether the rule applies to a row, column, or cell. To hide columns instead of rows, enter a value of 1 in the Target parameter:
Table2.Rules.AddNew(, 1)
See for a list of the targets you can specify.
You can hide both rows and columns on the same table by setting two rules for the table, as in the following example:
With Tables.AddNew("Table2", "education * before", _ "Education by before, hide zero rows and columns") .Rules.AddNew() ' default .Rules.AddNew(,1) ' rtColumn = 1 End With
Here is the table produced by the script:
This graphic is described in the surrounding text.
Instead of hiding rows or columns where all values are equal to zero, you can use different operators and values to set the condition. For example, the following script displays a table of museums by age, and hides any rows where all the values are less than or equal to 30, so that only the museums that attracted the most interest are shown. The fourth parameter, Operator, is set to 1 to specify “less than or equal to”. The fifth parameter, Value, specifies the value to test for:
See also
Hiding rows, columns, and cells