Table Properties using DocumentTools
The table properties control the appearance and behavior of a table in a worksheet or document.
In a document, tables are inserted using the Insert menu. The table is then customized by using the options in the Table Properties dialog. The Table Properties dialog is found in the Format > Table menu under Properties or through the context panel for a table.
For an overview of inserting and using tables in a document, including working with content in table cells, see Overview of Tables.
You can also access some table properties programmatically, as you can access embedded components. This help page describes the control and use of table properties programmatically.
The Name property is used to reference the table when using the routines from the DocumentTools package. For more information, see the Examples on this page.
Some table properties can be accessed programmatically using commands from the DocumentTools package. The following chart describes these table properties.
An x in the Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
An x in the Set column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.
string: left, center or right
true or false
string: all, none, left, top, right, bottom, horizontal, vertical
string: all, none, group
list or set
percentage given as a string
Specifies the alignment of the table. By default, the value is left.
Specifies if the table can be modified or not. The default is true.
Indicates how exterior borders are drawn. It can be any of the following: all, none, left, top, right, bottom, horizontal, vertical. The default is all.
Specifies the background color of the table. The color can be given by RGB values (a list of three integers between 0 and 255) or a string representing a color name, for example, [255,0,0] or “Red”. You can also use any color known to ColorTools[ToRGB24]. The default value is [255,255,255] which corresponds to white.
Specifies the background color of a row, where row is a positive integer or range.
Specifies the background color of a cell, where row and column are each a positive integer or range.
The reference name of the table.
Indicates how interior borders are drawn. It can be all, none, or group. The default is all.
Specify a caption for the table.
Specifies if the table is visible. By default, the value is true.
Specifies if a row of the table is visible, where row is a positive integer or range.
Specifies if a cell of the table is visible, where row and column are each a positive integer or range.
The width of the table as a percentage of the worksheet's width, e.g. "50%". The default is "100%".
For the fillcolor and visible properties, the DocumentTools commands may raise an error in the case of an invalid cell reference or mixed results. For example, consider a 2x2 table where the first row is merged into one cell. Referencing visible(1,1) would be OK but visible(1,2) would raise an error.
For examples demonstrating accessing or changing these properties programmatically, see the Examples below.
Note: To interact with the examples provided below, open this help page as a worksheet and then execute the worksheet.
When you insert a table, note its name in the Insert Table dialog. You can also check its name in the Table Properties for the table. The name of the table on the right is Table0.
Set the background color of one cell.
Set the background color of the second column to teal.
Return the table to its original state.
Download Help Document
What kind of issue would you like to report? (Optional)