lucee.Component
commandbox.system.util.TablePrinter
Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I print tables
| Property Summary | ||||
|---|---|---|---|---|
| type | property | default | serializable | required |
any
|
convert
|
true
|
false
|
|
any
|
job
|
true
|
false
|
|
any
|
print
|
true
|
false
|
|
any
|
shell
|
true
|
false
|
|
| Method Summary | |
|---|---|
private array
|
autoFormatData(array headers, array data)
Formats the data into an array of arrays. |
private struct
|
calculateColumnData(numeric index, string header, array data, [array headerNames='[runtime expression]'])
Calculates the max width of a column across the header and all rows of data. |
any
|
cellHasFormattingEmbedded([any data])
|
private array
|
getStructValues(struct item, array headers)
Gets the required keys from the struct of data and returns them as an array of arrays. |
private string
|
padRight(string text, numeric maxWidth, [string padChar=' '])
Adds characters to the right of a string until the string reaches a certain length. |
string
|
print(any data='[runtime expression]', [any includedHeaders=''], [any headerNames=''], [boolean debug='false'], [any width='-1'])
Outputs a table to the screen. |
private void
|
printData(array data, array headerData)
Prints all the data for the table. |
private void
|
printHeader(array headerData)
Prints the header row for the table. |
private void
|
printRow(array row, array headerData)
Prints a single row of data for the table. |
private void
|
printRowSeparator(array headerData)
Prints the separator between rows. |
private void
|
printTableEnd(array headerData)
Prints the final line of the table. |
array
|
processHeaders(array headers, array data, [any headerNames='[runtime expression]'], [any width='-1'])
Outputs a table to the screen. |
any
|
stringify([any data])
|
| Methods inherited from class lucee.Component |
|---|
| None |
| Property Detail |
|---|
access - publicrequired - falsereturntype - anyinject - DataConverterserializable - trueaccess - publicrequired - falsereturntype - anyinject - InteractiveJobserializable - trueaccess - publicrequired - falsereturntype - anyinject - PrintBufferserializable - trueaccess - publicrequired - falsereturntype - anyinject - shellserializable - true| Method Detail |
|---|
Formats the data into an array of arrays. If the data is an array of structs, the headers will be used to convert it to an array of arrays.
headers - The column headers for the table. Used as the lookup keys if data is an array of structs.data - The data for the table.Calculates the max width of a column across the header and all rows of data. This value is used to layout the table correctly.
index - The index of the column we are calculating.header - The column header.data - The data for the table.headerNames - Header name overridesdataGets the required keys from the struct of data and returns them as an array of arrays.
item - The struct of data representing a single row.headers - The column headers for the table used to get the needed data from the item in the correct order.Adds characters to the right of a string until the string reaches a certain length. If the text is already greater than or equal to the maxWidth, the text is returned unchanged.
text - The text to pad.maxWidth - The number of characters to pad up to.padChar - The character to use to pad the text.Outputs a table to the screen
data - Any type of data for the table. Each item in the array may either be an array in the correct order matching the number of headers or a struct with keys matching the headers.includedHeaders - A list of headers to include. Used for query inputsheaderNames - An list/array of column headers to use instead of the defaultdebug - Only print out the names of the columns and the first row valueswidth - Override the terminal widthPrints all the data for the table.
data - The data for the table.headerData - The array of column headers for the table with their corresponding max widths.Prints the header row for the table.
headerData - The array of column headers for the table with their corresponding max widths.Prints a single row of data for the table.
row - A single row of data for the table.headerData - The array of column headers for the table with their corresponding max widths.Prints the separator between rows.
headerData - The array of column headers for the table with their corresponding max widths.Prints the final line of the table.
headerData - The array of column headers for the table with their corresponding max widths.Outputs a table to the screen
headers - An array of column headers,data - An array of data for the table.headerNames - Header name overrideswidthdata