Here are the essential formatting methods you’ll use most often:
Font Styling
cell.format() .font_style({FontStyle::bold}) // bold, italic, underline, etc. .font_color(Color::red) // 8 colors available .font_background_color(Color::yellow) // background color .font_align(FontAlign::center); // left, center, right
Available font styles:
FontStyle::bold
FontStyle::italic
FontStyle::underline
FontStyle::blink
FontStyle::dark
FontStyle::crossed
FontStyle::reverse
Borders & Corners
table.format() .border_top("=") .border_bottom("=") .border_left("|") .border_right("|") .corner("+");// Or style all borders at oncetable.format().border("-");// Color borderstable.format() .border_color(Color::cyan) .corner_color(Color::magenta);
// Enable for UTF-8, emoji, CJK characterstable.format().multi_byte_characters(true);// Or for specific cells/columnstable.column(1).format().multi_byte_characters(true);
Tabulate provides intuitive access to rows, columns, and cells:
Table table;// ... add rows ...// Access a row by indexRow& row = table[0];row.format().font_color(Color::red);// Access a column by indexColumn col = table.column(1);col.format().font_align(FontAlign::right);// Access a specific celltable[0][1].format().font_style({FontStyle::bold});// Alternative: row then columntable.row(2).format().font_background_color(Color::blue);
// Iterate over all rowsfor (auto& row : table) { row.format().font_style({FontStyle::bold});}// Iterate over cells in a rowfor (auto& cell : table[0]) { cell.format().font_align(FontAlign::center);}// Iterate over cells in a columnfor (auto& cell : table.column(0)) { cell.format().font_color(Color::yellow);}