Struct papergrid::Grid [−][src]
pub struct Grid { /* fields omitted */ }Expand description
Grid provides a set of methods for building a text-based table
Implementations
The new method creates a grid instance with default styles.
The size of the grid can not be changed after the instance is created.
Example
use papergrid::{Grid, Entity, Settings, DEFAULT_CELL_STYLE};
let mut grid = Grid::new(2, 2);
grid.set_cell_borders(DEFAULT_CELL_STYLE.clone());
let str = grid.to_string();
assert_eq!(
str,
"+++\n\
|||\n\
+++\n\
|||\n\
+++\n"
)Set method is responsible for modification of cell/row/column.
The method panics if incorrect cell/row/column index is given.
Example
use papergrid::{Grid, Entity, Settings, DEFAULT_CELL_STYLE};
let mut grid = Grid::new(2, 2);
grid.set_cell_borders(DEFAULT_CELL_STYLE.clone());
grid.set(&Entity::Row(0), Settings::new().text("row 1"));
grid.set(&Entity::Row(1), Settings::new().text("row 2"));
let str = grid.to_string();
assert_eq!(
str,
"+-----+-----+\n\
|row 1|row 1|\n\
+-----+-----+\n\
|row 2|row 2|\n\
+-----+-----+\n"
)get_cell_settings returns a settings of a cell
get_cell_content returns content without any style changes
Count_rows returns an amount of rows on the grid
Count_rows returns an amount of columns on the grid
