summaryrefslogtreecommitdiffstats
path: root/examples/span.rs
blob: 61e18156cd6e4fe7e777393b46e09e7aafaa87c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#[macro_use]
extern crate prettytable;
use prettytable::{row::Row, cell::Cell, format::Alignment};


fn main() {

    /*
        The following code will output

        +---------------+---------------+--------------+
        |         A table with horizontal span         |
        +===============+===============+==============+
        | This is a cell with span of 2 | span of 1    |
        +---------------+---------------+--------------+
        | span of 1     | span of 1     | span of 1    |
        +---------------+---------------+--------------+
        |    This cell with a span of 3 is centered    |
        +---------------+---------------+--------------+
    */

    let mut table: prettytable::Table = table![
        [H2 -> "This is a cell with span of 2", "span of 1"],
        ["span of 1", "span of 1", "span of 1"],
        [H03c -> "This cell with a span of 3 is centered"]
        ];
    table.set_titles(Row::new(vec![
        Cell::new_align("A table with horizontal span", Alignment::CENTER).with_hspan(3)
    ]));
    table.printstd();
}