Prints a table.


int printTable ([string|shape shapeName, [mapping options,

[bool showDialog, [dyn_string header,

[dyn_string footer, [int columnsType,

[dyn_string | dyn_int columns,

[bool fitToPage, [bool landscape,

[bool gridLines, [bool gridBackground,

[dyn_int margin, [string printerName,

[string printFont]]]...]);


Parameter Description
shapeName The name of the table or a shape object. The default is an empty string "".

The options parameter can use different key/value pairs, all of which are optional. They gather the list of available arguments for this function into an easier entry format, keeping the same default values. The key will always be a string, whereas the value is given as the required data type.


The new functionality "useColor" was added to this list to use the background color in print.

showDialog bool (false)
header dyn_string (empty)
footer dyn_string (empty)
columnsType int (PT_VISIBLECOLUMNS)

dyn_string / dyn_int (empty)

This depends on the columnsType.

PT_NAMEDCOLUMNS will need a dyn_string, and PT_INDEXEDCOLUMNS will need a dyn_int.

fitToWidth bool (true)
landscape bool (true)
gridLines bool (true)
gridBackground bool (true)

dyn_int (20, 20, 20, 20)

The order of entries is: left, top, right, bottom.

printerName string (empty)
font string (font currently used by the table widget)

int (0)

  • 0 = No color is used.
  • 1 = The color defined in the cell will be used. If this is a dynamic color, then the first color will always be used.
  • 2 = When the color is dynamic, all color changes of a 2 second cycle will be shown in a horizontal "zebra-stripe" way (as dynamic colors are represented in the color selector).

    Anmerkung: This can only be used for printing background colors!
showDialog Open the printer dialog. The default is FALSE.

Header lines; Describes the format of headers. The following abbreviations may be used:

\date \time \page \name \user \numpages

The following parameters can be used for justification:

\left{...} \right{...} \center{...} \fill{...}

Line width and height are set by the paper format.

footer Footer lines. As for the "header" parameter.

Constant that defines the argument of columns.

PT_VISIBLECOLUMNS: visible columns are printed. (This is the default value)

PT_ALLCOLUMNS: all columns are printed.

PT_NAMEDCOLUMNS: the named columns defined in "columns" are printed.

PT_INDEXEDCOLUMNS: the columns defined in "columns" are printed.

columns Defines what columns have to be printed.
fitToPage Prints according to page size. The default is TRUE.
landscape Prints in landscape format. The default is TRUE.
gridLines Prints grid lines. The default is TRUE
gridBackground Prints every other line with another background color. The default is TRUE

Defines the margin in [mm]; The default value is (20,20,20,20)

margin[1] for left,

margin[2] for top,

margin[3] for right and

margin[4] for bottom.


Default is an empty string "", for example, dj560c. The default printer will be used, if no printer has been defined.


By using a file path the print can be directly sent to a .pdf file, e.g. "file:///C:/WinCC_OA_Proj/DemoApplication/temp.pdf"

printFont Optional parameter for setting the font size in the printout (e.g. Displaying in Font 10 and printing in Font 8). The required string is retrieved by using the function fileSelector().

Return value

The function printTable() returns 0 and with errors, -1.



The function printTable() prints the table shapeName with the specified settings.


The following example prints a table "Table1" with all columns and the current date. The print dialog opens. The column headers will be set to left justified. The page margins will be 22 millimeters. The table will be printed on the default printer. (A printer has not been defined in the code).

  string Table1 = "Table1";
//table name
  bool showDialog = TRUE;
//opens the print dialog
  dyn_string header = makeDynString("\\left{\\date}");
/* prints
    the date and sets the column headers to left justified */
  dyn_string column = makeDynString();
/* empty
    since the constant PT_ALLCOLUMNS defines that all columns are printed
    (the single columns of the table do not need to be defined separately)*/
  bool fitToPage = TRUE;
//defines that the printed table fits the page
  bool landscape = TRUE;
//defines that the table is printed in landscape format
  bool gridLines = TRUE;
//prints the gridlines
  bool gridBackground = TRUE;
/* Prints every second line with a different background color*/
  dyn_int margin = makeDynInt(22,22,22,22);
/* Defines the page margins in millimeters */

//Function call
  int print;
  print = printTable(Table1, showDialog,
                      header, footer, columnsType, column, fitToPage,
                      landscape, gridLines, gridBackground, margin);


Graphics functions



See also

printPanel(), printRootPanel(), Control Graphics - Table