PrintMatrix — Print out a table/matrix (e.g. query results).
PrintMatrix Matrix ?HeaderList? ?ColumnMaxWidthList?
Return Value
MatrixA list of lists. Every list has the same number of elements.
HeaderListOptional. Column headers to print at the top. By default prints nothing.
ColumnMaxWidthListOptional. List of values to use to limit the width of each column. By default column widths will each be big enough to fit max length cell in that column.
More Info
This is similar in functionality to the package report but is simpler (and less powerful).

Note that in the case of an empty list or empty string (which are not matrices), this command will not throw an error, but will rather print out a list of headers, if any, and exit.

To make a column width match the length of the longest string in it, you can put max rather than a number. PrintMatrix will then compute the max length for that column and use that.

Note that this will truncate cell contents if they go beyond the max width. Again, see report for something more full-featured.

For information regarding exceptions / errors, see here.
% set MyMatrix {{1 2 3} {4 5 6} {7 8 9}}
{1 2 3} {4 5 6} {7 8 9}
% PrintMatrix $MyMatrix
1 | 2 | 3
4 | 5 | 6
7 | 8 | 9
list, output, print