Printer Object
 
Syntax
 
Printer.TableCell(vsTableCellSettings[, Row1][, Col1][, Row2][, Col2]) = value
Description
Returns or sets properties of a table cell or range.
 
The TableCell property is used to build and format tables. Using TableCell requires four steps:
1) Initialise a table with the TableInit method.
2) Create the table using the TableAdd method, or using the TableCell property by itself.
3) Format the table using the TableCell property.
4) Close the table definition with the TableEnd method. This will render the table.
 
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 vsTableCellSettings parameter lets you access and modify virtually any aspect of a table. The vsTableCellSettings enumeration has over 40 values you can use. They are listed below, according to the type of formatting they provide.
 
The parameters for the TableCell property are described below.
 
Parameter
Description
vsTableCellSettings
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.
 
VsTableCellSettings
The settings listed below are grouped in logical order, affecting the entire table to affecting one cell only:
 
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
tcColWidt
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.
 
See Also
Example
 
Sub Main
Dim i As Integer
Dim r%, c%
 
With Printer
   'Printer object activeren:
   If Not .Init() Then End
 
   'create table with 4 rows and 4 columns
   .TableCell(tcCols) = 4
   .TableCell(tcRows) = 4
 
   'set some column widths (default is 0.5in)
   .TableCell(tcColWidth, , 1) = "1in"
   .TableCell(tcColWidth, , 2) = "1.3in"
  
   'assign text to each cell
   For r = 1 To 4
      For c = 1 To 4
         .TableCell(tcText, r, c) = "Row " & r & " Col " & c
      Next c
   Next r
 
   'format cell (1,1): make it span two
   'columns, with a blue background,
   'centered alignment, and bold
   .TableCell(tcColSpan, 1, 1) = 2
   .TableCell(tcBackColor, 1, 1) = vbBlue
   .TableCell(tcAlign, 1, 1) = taCenterMiddle
   .TableCell(tcFontBold, 1, 1) = True
 
   'set row height for row 1
   '(default height calculated to fit content)
   .TableCell(tcRowHeight, 1) = "0.2in"
  
   'format cell (3,2): make is span two
   'columns, with a yellow background,
   'centered alignment, and bold
   .TableCell(tcColSpan, 3, 2) = 2
   .TableCell(tcBackColor, 3, 2) = vbYellow
   .TableCell(tcAlign, 3, 2) = taCenterMiddle
   .TableCell(tcFontBold, 3, 2) = True
 
   'set row height for row 3
   .TableCell(tcRowHeight, 3) = "0.2in"
 
   'set row borders all around
   .TableBorder = tbAll
 
   'finish table definition
   .Submit
 
End With
 
End Sub