Documentation ¶
Index ¶
- Constants
- Variables
- type BoxStyle
- type ColorOptions
- type FormatOptions
- type Options
- type Row
- type Style
- type Table
- func (t *Table) AppendFooter(row Row)
- func (t *Table) AppendHeader(row Row)
- func (t *Table) AppendRow(row Row)
- func (t *Table) AppendRows(rows []Row)
- func (t *Table) Length() int
- func (t *Table) Render() string
- func (t *Table) RenderCSV() string
- func (t *Table) RenderHTML() string
- func (t *Table) RenderMarkdown() string
- func (t *Table) SetAlign(align []text.Align)
- func (t *Table) SetAlignFooter(align []text.Align)
- func (t *Table) SetAlignHeader(align []text.Align)
- func (t *Table) SetAllowedColumnLengths(lengths []int)
- func (t *Table) SetAllowedRowLength(length int)
- func (t *Table) SetAutoIndex(autoIndex bool)
- func (t *Table) SetCaption(format string, a ...interface{})
- func (t *Table) SetColors(colors []text.Colors)
- func (t *Table) SetColorsFooter(colors []text.Colors)
- func (t *Table) SetColorsHeader(colors []text.Colors)
- func (t *Table) SetHTMLCSSClass(cssClass string)
- func (t *Table) SetOutputMirror(mirror io.Writer)
- func (t *Table) SetStyle(style Style)
- func (t *Table) SetVAlign(vAlign []text.VAlign)
- func (t *Table) SetVAlignFooter(vAlign []text.VAlign)
- func (t *Table) SetVAlignHeader(vAlign []text.VAlign)
- func (t *Table) Style() *Style
- type Writer
Constants ¶
const ( // DefaultHTMLCSSClass stores the css-class to use when none-provided via // SetHTMLCSSClass(cssClass string). DefaultHTMLCSSClass = "go-pretty-table" )
Variables ¶
var ( // StyleDefault renders a Table like below: // +-----+------------+-----------+--------+-----------------------------+ // | # | FIRST NAME | LAST NAME | SALARY | | // +-----+------------+-----------+--------+-----------------------------+ // | 1 | Arya | Stark | 3000 | | // | 20 | Jon | Snow | 2000 | You know nothing, Jon Snow! | // | 300 | Tyrion | Lannister | 5000 | | // +-----+------------+-----------+--------+-----------------------------+ // | | | TOTAL | 10000 | | // +-----+------------+-----------+--------+-----------------------------+ StyleDefault = Style{ Name: "StyleDefault", Box: StyleBoxDefault, Color: ColorOptionsDefault, Format: FormatOptionsDefault, Options: OptionsDefault, } // StyleBold renders a Table like below: // ┏━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ // ┃ # ┃ FIRST NAME ┃ LAST NAME ┃ SALARY ┃ ┃ // ┣━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ // ┃ 1 ┃ Arya ┃ Stark ┃ 3000 ┃ ┃ // ┃ 20 ┃ Jon ┃ Snow ┃ 2000 ┃ You know nothing, Jon Snow! ┃ // ┃ 300 ┃ Tyrion ┃ Lannister ┃ 5000 ┃ ┃ // ┣━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ // ┃ ┃ ┃ TOTAL ┃ 10000 ┃ ┃ // ┗━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ StyleBold = Style{ Name: "StyleBold", Box: StyleBoxBold, Color: ColorOptionsDefault, Format: FormatOptionsDefault, Options: OptionsDefault, } // StyleColoredBright renders a Table without any borders or separators, and // with every row colored with a Bright background. StyleColoredBright = Style{ Name: "StyleColoredBright", Box: StyleBoxDefault, Color: ColorOptionsBright, Format: FormatOptionsDefault, Options: OptionsNoBordersAndSeparators, } // StyleColoredDark renders a Table without any borders or separators, and // with every row colored with a Dark background. StyleColoredDark = Style{ Name: "StyleColoredDark", Box: StyleBoxDefault, Color: ColorOptionsDark, Format: FormatOptionsDefault, Options: OptionsNoBordersAndSeparators, } // StyleDouble renders a Table like below: // ╔═════╦════════════╦═══════════╦════════╦═════════════════════════════╗ // ║ # ║ FIRST NAME ║ LAST NAME ║ SALARY ║ ║ // ╠═════╬════════════╬═══════════╬════════╬═════════════════════════════╣ // ║ 1 ║ Arya ║ Stark ║ 3000 ║ ║ // ║ 20 ║ Jon ║ Snow ║ 2000 ║ You know nothing, Jon Snow! ║ // ║ 300 ║ Tyrion ║ Lannister ║ 5000 ║ ║ // ╠═════╬════════════╬═══════════╬════════╬═════════════════════════════╣ // ║ ║ ║ TOTAL ║ 10000 ║ ║ // ╚═════╩════════════╩═══════════╩════════╩═════════════════════════════╝ StyleDouble = Style{ Name: "StyleDouble", Box: StyleBoxDouble, Color: ColorOptionsDefault, Format: FormatOptionsDefault, Options: OptionsDefault, } // StyleLight renders a Table like below: // ┌─────┬────────────┬───────────┬────────┬─────────────────────────────┐ // │ # │ FIRST NAME │ LAST NAME │ SALARY │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ 1 │ Arya │ Stark │ 3000 │ │ // │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ // │ 300 │ Tyrion │ Lannister │ 5000 │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ │ │ TOTAL │ 10000 │ │ // └─────┴────────────┴───────────┴────────┴─────────────────────────────┘ StyleLight = Style{ Name: "StyleLight", Box: StyleBoxLight, Color: ColorOptionsDefault, Format: FormatOptionsDefault, Options: OptionsDefault, } // StyleRounded renders a Table like below: // ╭─────┬────────────┬───────────┬────────┬─────────────────────────────╮ // │ # │ FIRST NAME │ LAST NAME │ SALARY │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ 1 │ Arya │ Stark │ 3000 │ │ // │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ // │ 300 │ Tyrion │ Lannister │ 5000 │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ │ │ TOTAL │ 10000 │ │ // ╰─────┴────────────┴───────────┴────────┴─────────────────────────────╯ StyleRounded = Style{ Name: "StyleRounded", Box: StyleBoxRounded, Color: ColorOptionsDefault, Format: FormatOptionsDefault, Options: OptionsDefault, } )
var ( // StyleBoxDefault defines a Boxed-Table like below: // +-----+------------+-----------+--------+-----------------------------+ // | # | FIRST NAME | LAST NAME | SALARY | | // +-----+------------+-----------+--------+-----------------------------+ // | 1 | Arya | Stark | 3000 | | // | 20 | Jon | Snow | 2000 | You know nothing, Jon Snow! | // | 300 | Tyrion | Lannister | 5000 | | // +-----+------------+-----------+--------+-----------------------------+ // | | | TOTAL | 10000 | | // +-----+------------+-----------+--------+-----------------------------+ StyleBoxDefault = BoxStyle{ BottomLeft: "+", BottomRight: "+", BottomSeparator: "+", Left: "|", LeftSeparator: "+", MiddleHorizontal: "-", MiddleSeparator: "+", MiddleVertical: "|", PaddingLeft: " ", PaddingRight: " ", Right: "|", RightSeparator: "+", TopLeft: "+", TopRight: "+", TopSeparator: "+", UnfinishedRow: " ~", } // StyleBoxBold defines a Boxed-Table like below: // ┏━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ // ┃ # ┃ FIRST NAME ┃ LAST NAME ┃ SALARY ┃ ┃ // ┣━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ // ┃ 1 ┃ Arya ┃ Stark ┃ 3000 ┃ ┃ // ┃ 20 ┃ Jon ┃ Snow ┃ 2000 ┃ You know nothing, Jon Snow! ┃ // ┃ 300 ┃ Tyrion ┃ Lannister ┃ 5000 ┃ ┃ // ┣━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ // ┃ ┃ ┃ TOTAL ┃ 10000 ┃ ┃ // ┗━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ StyleBoxBold = BoxStyle{ BottomLeft: text.BoxBottomLeftBold, BottomRight: text.BoxBottomRightBold, BottomSeparator: text.BoxBottomSeparatorBold, Left: text.BoxLeftBold, LeftSeparator: text.BoxLeftSeparatorBold, MiddleHorizontal: text.BoxHorizontalBold, MiddleSeparator: text.BoxSeparatorBold, MiddleVertical: text.BoxVerticalBold, PaddingLeft: " ", PaddingRight: " ", Right: text.BoxRightBold, RightSeparator: text.BoxRightSeparatorBold, TopLeft: text.BoxTopLeftBold, TopRight: text.BoxTopRightBold, TopSeparator: text.BoxTopSeparatorBold, UnfinishedRow: " " + text.BoxUnfinishedLine, } // StyleBoxDouble defines a Boxed-Table like below: // ╔═════╦════════════╦═══════════╦════════╦═════════════════════════════╗ // ║ # ║ FIRST NAME ║ LAST NAME ║ SALARY ║ ║ // ╠═════╬════════════╬═══════════╬════════╬═════════════════════════════╣ // ║ 1 ║ Arya ║ Stark ║ 3000 ║ ║ // ║ 20 ║ Jon ║ Snow ║ 2000 ║ You know nothing, Jon Snow! ║ // ║ 300 ║ Tyrion ║ Lannister ║ 5000 ║ ║ // ╠═════╬════════════╬═══════════╬════════╬═════════════════════════════╣ // ║ ║ ║ TOTAL ║ 10000 ║ ║ // ╚═════╩════════════╩═══════════╩════════╩═════════════════════════════╝ StyleBoxDouble = BoxStyle{ BottomLeft: text.BoxBottomLeftDouble, BottomRight: text.BoxBottomRightDouble, BottomSeparator: text.BoxBottomSeparatorDouble, Left: text.BoxLeftDouble, LeftSeparator: text.BoxLeftSeparatorDouble, MiddleHorizontal: text.BoxHorizontalDouble, MiddleSeparator: text.BoxSeparatorDouble, MiddleVertical: text.BoxVerticalDouble, PaddingLeft: " ", PaddingRight: " ", Right: text.BoxRightDouble, RightSeparator: text.BoxRightSeparatorDouble, TopLeft: text.BoxTopLeftDouble, TopRight: text.BoxTopRightDouble, TopSeparator: text.BoxTopSeparatorDouble, UnfinishedRow: " " + text.BoxUnfinishedLine, } // StyleBoxLight defines a Boxed-Table like below: // ┌─────┬────────────┬───────────┬────────┬─────────────────────────────┐ // │ # │ FIRST NAME │ LAST NAME │ SALARY │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ 1 │ Arya │ Stark │ 3000 │ │ // │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ // │ 300 │ Tyrion │ Lannister │ 5000 │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ │ │ TOTAL │ 10000 │ │ // └─────┴────────────┴───────────┴────────┴─────────────────────────────┘ StyleBoxLight = BoxStyle{ BottomLeft: text.BoxBottomLeft, BottomRight: text.BoxBottomRight, BottomSeparator: text.BoxBottomSeparator, Left: text.BoxLeft, LeftSeparator: text.BoxLeftSeparator, MiddleHorizontal: text.BoxHorizontal, MiddleSeparator: text.BoxSeparator, MiddleVertical: text.BoxVertical, PaddingLeft: " ", PaddingRight: " ", Right: text.BoxRight, RightSeparator: text.BoxRightSeparator, TopLeft: text.BoxTopLeft, TopRight: text.BoxTopRight, TopSeparator: text.BoxTopSeparator, UnfinishedRow: " " + text.BoxUnfinishedLine, } // StyleBoxRounded defines a Boxed-Table like below: // ╭─────┬────────────┬───────────┬────────┬─────────────────────────────╮ // │ # │ FIRST NAME │ LAST NAME │ SALARY │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ 1 │ Arya │ Stark │ 3000 │ │ // │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ // │ 300 │ Tyrion │ Lannister │ 5000 │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ │ │ TOTAL │ 10000 │ │ // ╰─────┴────────────┴───────────┴────────┴─────────────────────────────╯ StyleBoxRounded = BoxStyle{ BottomLeft: text.BoxBottomLeftRounded, BottomRight: text.BoxBottomRightRounded, BottomSeparator: text.BoxBottomSeparator, Left: text.BoxLeft, LeftSeparator: text.BoxLeftSeparator, MiddleHorizontal: text.BoxHorizontal, MiddleSeparator: text.BoxSeparator, MiddleVertical: text.BoxVertical, PaddingLeft: " ", PaddingRight: " ", Right: text.BoxRight, RightSeparator: text.BoxRightSeparator, TopLeft: text.BoxTopLeftRounded, TopRight: text.BoxTopRightRounded, TopSeparator: text.BoxTopSeparator, UnfinishedRow: " " + text.BoxUnfinishedLine, } )
var ( // ColorOptionsDefault defines sensible ANSI color options - basically NONE. ColorOptionsDefault = ColorOptions{ AutoIndexColumn: nil, FirstColumn: nil, Footer: nil, Header: nil, Row: nil, RowAlternate: nil, } // ColorOptionsBright defines ANSI color options to render dark text on // bright background. ColorOptionsBright = ColorOptions{ AutoIndexColumn: text.Colors{color.BgHiCyan, color.FgBlack}, FirstColumn: nil, Footer: text.Colors{color.BgCyan, color.FgBlack}, Header: text.Colors{color.BgHiCyan, color.FgBlack}, Row: text.Colors{color.BgHiWhite, color.FgBlack}, RowAlternate: text.Colors{color.BgWhite, color.FgBlack}, } // ColorOptionsDark defines ANSI color options to render bright text on dark // background. ColorOptionsDark = ColorOptions{ AutoIndexColumn: text.Colors{color.FgHiCyan, color.BgBlack}, FirstColumn: nil, Footer: text.Colors{color.FgCyan, color.BgBlack}, Header: text.Colors{color.FgHiCyan, color.BgBlack}, Row: text.Colors{color.FgHiWhite, color.BgBlack}, RowAlternate: text.Colors{color.FgWhite, color.BgBlack}, } )
var ( // OptionsDefault defines sensible global options. OptionsDefault = Options{ DrawBorder: true, SeparateColumns: true, SeparateFooter: true, SeparateHeader: true, SeparateRows: false, } // OptionsNoBorders sets up a table without any borders. OptionsNoBorders = Options{ DrawBorder: false, SeparateColumns: true, SeparateFooter: true, SeparateHeader: true, SeparateRows: false, } // OptionsNoBordersAndSeparators sets up a table without any borders or // separators. OptionsNoBordersAndSeparators = Options{ DrawBorder: false, SeparateColumns: false, SeparateFooter: false, SeparateHeader: false, SeparateRows: false, } )
var ( // FormatOptionsDefault defines sensible formatting options. FormatOptionsDefault = FormatOptions{ Footer: text.FormatUpper, Header: text.FormatUpper, Row: text.FormatDefault, } )
Functions ¶
This section is empty.
Types ¶
type BoxStyle ¶
type BoxStyle struct { BottomLeft string BottomRight string BottomSeparator string Left string LeftSeparator string MiddleHorizontal string MiddleSeparator string MiddleVertical string PaddingLeft string PaddingRight string Right string RightSeparator string TopLeft string TopRight string TopSeparator string UnfinishedRow string }
BoxStyle defines the characters/strings to use to render the borders and separators for the Table.
type ColorOptions ¶
type ColorOptions struct { AutoIndexColumn text.Colors FirstColumn text.Colors Header text.Colors Row text.Colors RowAlternate text.Colors }
ColorOptions defines the ANSI colors to use for parts of the Table.
type FormatOptions ¶
FormatOptions defines the text-formatting to perform on parts of the Table.
type Options ¶
type Options struct { // DrawBorder enables or disables drawing the border around the Table. // Example of a table where it is disabled: // # │ FIRST NAME │ LAST NAME │ SALARY │ // ─────┼────────────┼───────────┼────────┼───────────────────────────── // 1 │ Arya │ Stark │ 3000 │ // 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! // 300 │ Tyrion │ Lannister │ 5000 │ // ─────┼────────────┼───────────┼────────┼───────────────────────────── // │ │ TOTAL │ 10000 │ DrawBorder bool // SeparateColumns enables or disable drawing border between columns. // Example of a table where it is disabled: // ┌─────────────────────────────────────────────────────────────────┐ // │ # FIRST NAME LAST NAME SALARY │ // ├─────────────────────────────────────────────────────────────────┤ // │ 1 Arya Stark 3000 │ // │ 20 Jon Snow 2000 You know nothing, Jon Snow! │ // │ 300 Tyrion Lannister 5000 │ // │ TOTAL 10000 │ // └─────────────────────────────────────────────────────────────────┘ SeparateColumns bool // the rows. Example of a table where it is disabled: // ┌─────┬────────────┬───────────┬────────┬─────────────────────────────┐ // │ # │ FIRST NAME │ LAST NAME │ SALARY │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ 1 │ Arya │ Stark │ 3000 │ │ // │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ // │ 300 │ Tyrion │ Lannister │ 5000 │ │ // │ │ │ TOTAL │ 10000 │ │ // └─────┴────────────┴───────────┴────────┴─────────────────────────────┘ SeparateFooter bool // SeparateHeader enables or disable drawing border between the header and // the rows. Example of a table where it is disabled: // ┌─────┬────────────┬───────────┬────────┬─────────────────────────────┐ // │ # │ FIRST NAME │ LAST NAME │ SALARY │ │ // │ 1 │ Arya │ Stark │ 3000 │ │ // │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ // │ 300 │ Tyrion │ Lannister │ 5000 │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ │ │ TOTAL │ 10000 │ │ // └─────┴────────────┴───────────┴────────┴─────────────────────────────┘ SeparateHeader bool // SeparateRows enables or disables drawing separators between each row. // Example of a table where it is enabled: // ┌─────┬────────────┬───────────┬────────┬─────────────────────────────┐ // │ # │ FIRST NAME │ LAST NAME │ SALARY │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ 1 │ Arya │ Stark │ 3000 │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ 300 │ Tyrion │ Lannister │ 5000 │ │ // ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ // │ │ │ TOTAL │ 10000 │ │ // └─────┴────────────┴───────────┴────────┴─────────────────────────────┘ SeparateRows bool }
Options defines the global options that determine how the Table is rendered.
type Style ¶
type Style struct { Name string Box BoxStyle Color ColorOptions Format FormatOptions Options Options }
Style declares how to render the Table and provides very fine-grained control on how the Table gets rendered on the Console.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table helps print a 2-dimensional array in a human readable pretty-table.
func (*Table) AppendFooter ¶
AppendFooter appends the row to the List of footers to render.
func (*Table) AppendHeader ¶
AppendHeader appends the row to the List of headers to render.
func (*Table) AppendRows ¶
AppendRows appends the rows to the List of rows to render.
func (*Table) Render ¶
Render renders the Table in a human-readable "pretty" format. Example:
┌─────┬────────────┬───────────┬────────┬─────────────────────────────┐ │ # │ FIRST NAME │ LAST NAME │ SALARY │ │ ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ │ 1 │ Arya │ Stark │ 3000 │ │ │ 20 │ Jon │ Snow │ 2000 │ You know nothing, Jon Snow! │ │ 300 │ Tyrion │ Lannister │ 5000 │ │ ├─────┼────────────┼───────────┼────────┼─────────────────────────────┤ │ │ │ TOTAL │ 10000 │ │ └─────┴────────────┴───────────┴────────┴─────────────────────────────┘
func (*Table) RenderCSV ¶
RenderCSV renders the Table in CSV format. Example:
#,First Name,Last Name,Salary, 1,Arya,Stark,3000, 20,Jon,Snow,2000,"You know nothing\, Jon Snow!" 300,Tyrion,Lannister,5000, ,,Total,10000,
func (*Table) RenderHTML ¶
RenderHTML renders the Table in HTML format. Example:
<table class="go-pretty-table"> <thead> <tr> <th align="right">#</th> <th>First Name</th> <th>Last Name</th> <th align="right">Salary</th> <th> </th> </tr> </thead> <tbody> <tr> <td align="right">1</td> <td>Arya</td> <td>Stark</td> <td align="right">3000</td> <td> </td> </tr> <tr> <td align="right">20</td> <td>Jon</td> <td>Snow</td> <td align="right">2000</td> <td>You know nothing, Jon Snow!</td> </tr> <tr> <td align="right">300</td> <td>Tyrion</td> <td>Lannister</td> <td align="right">5000</td> <td> </td> </tr> </tbody> <tfoot> <tr> <td align="right"> </td> <td> </td> <td>Total</td> <td align="right">10000</td> <td> </td> </tr> </tfoot> </table>
func (*Table) RenderMarkdown ¶
RenderMarkdown renders the Table in Markdown format. Example:
| # | First Name | Last Name | Salary | | | ---:| --- | --- | ---:| --- | | 1 | Arya | Stark | 3000 | | | 20 | Jon | Snow | 2000 | You know nothing, Jon Snow! | | 300 | Tyrion | Lannister | 5000 | | | | | Total | 10000 | |
func (*Table) SetAlignFooter ¶
SetAlignFooter sets the horizontal-align for each column in the footer.
func (*Table) SetAlignHeader ¶
SetAlignHeader sets the horizontal-align for each column in the header.
func (*Table) SetAllowedColumnLengths ¶
SetAllowedColumnLengths sets the maximum allowed length for each column in all the rows. Columns with content longer than the allowed limit will be wrapped to fit the length. Length has to be a positive value to take effect.
func (*Table) SetAllowedRowLength ¶
SetAllowedRowLength sets the maximum allowed length or a row (or line of output) when rendered as a table. Rows that are longer than this limit will be "snipped" to the length. Length has to be a positive value to take effect.
func (*Table) SetAutoIndex ¶
SetAutoIndex adds a generated header with columns such as "A", "B", "C", etc. and a leading column with the row number similar to what you'd see on any spreadsheet application. NOTE: Appending a Header will void this functionality.
func (*Table) SetCaption ¶
SetCaption sets the text to be rendered just below the table. This will not show up when the Table is rendered as a CSV.
func (*Table) SetColorsFooter ¶
SetColorsFooter sets the colors for the rows in the Footer.
func (*Table) SetColorsHeader ¶
SetColorsHeader sets the colors for the rows in the Header.
func (*Table) SetHTMLCSSClass ¶
SetHTMLCSSClass sets the the HTML CSS Class to use on the <table> node when rendering the Table in HTML format.
func (*Table) SetOutputMirror ¶
SetOutputMirror sets an io.Writer for all the Render functions to "Write" to in addition to returning a string.
func (*Table) SetVAlignFooter ¶
SetVAlignFooter sets the horizontal-align for each column in the footer.
func (*Table) SetVAlignHeader ¶
SetVAlignHeader sets the horizontal-align for each column in the header.
type Writer ¶
type Writer interface { AppendHeader(row Row) AppendRow(row Row) AppendRows(rows []Row) Length() int Render() string RenderCSV() string RenderHTML() string RenderMarkdown() string SetAlign(align []text.Align) SetAlignHeader(align []text.Align) SetAllowedColumnLengths(lengths []int) SetAllowedRowLength(length int) SetAutoIndex(autoIndex bool) SetCaption(format string, a ...interface{}) SetColors(colors []text.Colors) SetColorsHeader(colors []text.Colors) SetHTMLCSSClass(cssClass string) SetOutputMirror(mirror io.Writer) SetStyle(style Style) SetVAlign(vAlign []text.VAlign) SetVAlignHeader(vAlign []text.VAlign) Style() *Style }
Writer declares the interfaces that can be used to setup and render a table.