Easily Create Tables in Terminal with C++
A C++ library that facilitates the development of your TUI applications.
TUI (Terminal User Interface) applications are growing day by day. And for you to display table data in the terminal with colors and other features, for C++ developers there is one more library that is very simple to use: Tabulate .
To use Tabulate in your applications, just install it on your system and for that you will need the following dependencies:
Usually C++ programmers already have them all installed, but just in case… 😃
After that, just clone and install with the following commands:
There are several ways to apply Tabulate in your code, however, the most basic way would be:
- Include library:
- Use namespace directly or with using:
using namespace tabulate;
- Instantiate the class:
- And use the code as needed.
In this basic example we print two cells with predefined widths as desired:
To compile you don’t need any additional flag, example:
Note that to print the table you must use
std::cout << table_name << '\n'; . And to add features, formatting, colors and others you can do union in your class instance, for example adding color would be:
table.format().font_color(Color::yellow);, in this case according to the example above the
 indicates that the output of the cell on the left will now be colored yellow .
For a more detailed example you can use the samples/ directory, example:
The possible output will be:
If you want to uninstall Tabulate, run:
For more examples and information visit the official repository .