Control Reference > VSPrinter Control > VSPrinter Properties > TableCell Property |
Returns or sets properties of a table cell or range.
[form!]VSPrinter.TableCell(Setting As TableCellSettings, [ Row1 As Variant ], [ Col1 As Variant ], [ Row2 As Variant ], [ Col2 As Variant ]) [ = value As Variant ]
The TableCell property is used to build and format tables. Using TableCell requires four steps:
1. Start a table definition with the StartTable method.
2. Create the table using the AddTable or AddTableArray methods, or using the TableCell property by itself.
3. Format the table using the TableCell property.
4. Close the table definition with the EndTable method. This will render the table.
The parameters for the TableCell property are described below:
Parameter |
Description |
Setting |
Determines which property of the table, row, column, or cell you want to set or retrieve. The list of valid settings is given below. |
Row1 |
First row in the range. The header row has index zero. Body rows are one-based. |
Col1 |
First column in the range. The first column has index one. |
Row2 |
Last row in the range. Optional, defaults to Row1. |
Col2 |
Last column in the range. Optional, defaults to Col1. |
Setting the TableCell property affects the range of cells specified by the Row1, Col1, Row2, and Col2 parameters. Getting the TableCell property retrieves properties from the cell specified by the Row1 and Col1 parameters. Some parameters apply to the whole table, others to entire rows or columns. In these cases, one or more of the range parameters are ignored.
The TableCell property is very powerful because the Setting parameter lets you access and modify virtually any aspect of a table. The TableCellSettings enumeration has over 40 values you can use. They are listed below, according to the type of formatting they provide.
Table Properties: These settings affect the entire table.
Constant |
Value |
Description |
tcIndent |
0 |
Returns or sets the indent for the table. You may specify units with this value (the default unit is twips). |
tcRows |
1 |
Returns or sets the number of rows on the table. The header row is not included in this count. If you change the number of rows, rows are added or deleted from the bottom of the table. |
tcCols |
2 |
Returns or sets the number of columns on the table. If you change the number of columns, columns are added or deleted from the right of the table. |
tcInsertRow |
3 |
Inserts a row at the specified position (Row1). |
tcInsertCol |
4 |
Inserts a column at the specified position (Col1). |
tcDeleteRow |
5 |
Deletes the row at the specified position (Row1). |
tcDeleteCol |
6 |
Deletes the column at the specified position (Col1). |
Row Properties: These settings affect entire rows or row ranges. The Col1 and Col2 parameters are ignored:
Constant |
Value |
Description |
tcRowHeight |
7 |
Returns or sets the height of the rows. The header row has index zero. You may specify units with this value (the default unit is twips). |
tcRowBorder |
8 |
Returns or sets whether the rows will have a border drawn above them. Possible values are: 0 (no border), 1 (force border), and 2 (honor TableBorder setting). |
tcRowData |
9 |
Returns or sets a Variant associated with the row. This value is for your own use, and is not used by the control. |
tcRowSource |
10 |
Returns or sets the array row used as a data source for the table row. This setting only applies if the table was bound to an array (with the AddTableArray method). Note that array indices are zero-based, and table indices are one-based. |
tcRowKeepWithNext |
11 |
Returns or sets whether the control should prevent page breaks after the rows. |
tcRowIsSubHeader |
12 |
Returns or sets whether the row should become the table header after it is rendered (useful for subtitles). |
tcRowSpaceBefore |
34 |
Returns or sets the amount of vertical space to insert before each cell on the row. |
tcRowSpaceAfter |
35 |
Returns or sets the amount of vertical space to insert after each cell on the row. |
tcRowBorderAbove |
36 |
Returns or sets the thickness of a custom border to be drawn above the row. |
tcRowBorderBelow |
37 |
Returns or sets the thickness of a custom border to be drawn below the row. |
tcRowBorderColor |
38 |
Returns or sets the color of the custom borders drawn above and below the row. |
tcRowNewPage |
39 |
Returns or sets whether the row should be the first on a page (forcing a page break if necessary). |
tcRowKeepTogether |
40 |
Returns or sets whether the row should be kept together on a page or whether it can be broken and rendered on two pages. |
Column Properties: These settings affect entire columns or column ranges. The Row1 and Row2 parameters are ignored:
Constant |
Value |
Description |
tcColWidth |
13 |
Returns or sets the width of the columns. You may specify units with this value (the default unit is twips). |
tcColBorder |
14 |
Returns or sets whether the columns will have a border drawn on their right-hand side. Possible values are: 0 (no border), 1 (force border), and 2 (honor TableBorder setting). |
tcColData |
15 |
Returns or sets a Variant associated with the column. This value is for your own use, and is not used by the control. |
tcColSource |
16 |
Returns or sets the array column used as a data source for the table column. This setting only applies if the table was bound to an array (with the AddTableArray method). Note that array indices are zero-based, and table indices are one-based. |
tcColAlign |
31 |
Returns or sets the alignment for the column. Valid settings are the same used with the TextAlign property. |
tcColNoWrap |
32 |
Returns or sets whether long text entries should be allowed to wrap within cells on this column. |
tcColSkipRepeats |
33 |
Returns or sets whether repeated text entries (with the same text as the cell above) should be skipped on this column. |
tcColBorderLeft |
43 |
Returns or sets the thickness of a custom border to be drawn to the left of this column. |
tcColBorderRight |
44 |
Returns or sets the thickness of a custom border to be drawn to the right of this column. |
tcColBorderColor |
45 |
Returns or sets the color of the custom borders drawn to the left and right of this column. |
Cell Properties: These settings affect individual cells or cell ranges:
Constant |
Value |
Description |
|
tcColSpan |
17 |
Returns or sets the number of columns that the cell should span (column merging). |
|
tcText |
18 |
Returns or sets the cell text. If the table is bound to an array, setting the property will change the table, but not the source array. |
|
tcAlign |
19 |
Returns or sets the alignment of text in the cells. Valid settings are the same used with the TextAlign property. |
|
tcBackColor |
20 |
Returns or sets the background color for the cell. |
|
tcForeColor |
21 |
Returns or sets the foreground (text) color for the cell. |
|
tcFont |
22 |
Returns or sets the cell font. |
|
tcFontName |
23 |
Returns or sets the name of the cell font. |
|
tcFontSize |
24 |
Returns or sets the size of the cell font. |
|
tcFontBold |
25 |
Returns or sets the bold attribute of the cell font. |
|
tcFontItalic |
26 |
Returns or sets the italic attribute of the cell font. |
|
tcFontUnderline |
27 |
Returns or sets the underline of the cell font. |
|
tcFontStrikethru |
28 |
Returns or sets the strikethrough attribute of the cell font. |
|
tcPicture |
29 |
Returns or sets the cell picture. |
|
tcPictureAlign |
30 |
Returns or sets the alignment of pictures in the cells. Valid settings are the same used with the TextAlign property. |
|
tcRowSpan |
41 |
Returns or sets the number of rows that the cell should span (row merging). |
|
tcVertical |
42 |
Returns or sets whether the cell text should be rendered in the vertical direction. |
|
tcAlignCurrency |
46 |
Aligns to the right and accounts for parenthesis. Negative currency values are often shown enclosed in parenthesis. |
The Table Formatting example shows how you can use the TableCell property to create and format a table.
Variant