p-ranav / tabulate

Table Maker for Modern C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I acheive this table formatting?

JapanIsShinto opened this issue · comments

I am having a hard time understanding the various table formatting options. I have code that makes a table that looks like this. The only formatting I have added is to center text in each column and to set the cell width equally to all interior cells:

+---+----------------+----------------+----------------+----------------+----------------+----------------+
|   |        A       |        B       |        C       |        D       |        E       |        F       |
+---+----------------+----------------+----------------+----------------+----------------+----------------+
| 1 |   588 490 472  |  1023 913 861  |   689 739 911  |   580 620 539  |   758 708 875  |   704 870 880  |
+---+----------------+----------------+----------------+----------------+----------------+----------------+
| 2 |  1022 784 571  |   575 577 880  |  1023 692 690  |   573 438 596  |   901 982 740  |   979 836 601  |
+---+----------------+----------------+----------------+----------------+----------------+----------------+
| 3 |   378 381 666  |   598 766 645  |   923 534 503  |  1022 1010 748 |   967 652 809  |   464 643 814  |
+---+----------------+----------------+----------------+----------------+----------------+----------------+
| 4 | 1023 1015 1023 | 1023 1012 1023 |   965 961 991  |   712 708 735  |   489 483 518  |   293 279 320  |
+---+----------------+----------------+----------------+----------------+----------------+----------------+

What I want is this formatting:

            A                B                C                D                E                F       
   +----------------+----------------+----------------+----------------+----------------+----------------
 1 |   588 490 473     1023 913 862      689 739 911      581 621 539      759 709 876      705 870 881   
 2 |  1022 784 572      575 577 881     1023 692 690      573 439 596      901 982 740      980 837 601   
 3 |   379 382 667      599 767 645      923 535 504     1023 1010 749     967 653 810      464 643 814   
 4 | 1023 1015 1023   1023 1013 1023     966 962 992      713 708 736      489 483 519      294 280 320  

What do I need to achieve this? I've played with various combinations of hiding borders, changing border and corner characters, and other things, but the result is usually parts look like what I want, and other parts are wrong. I think I'm just missing some core concepts in the rendering model, or possibly how I'm specifying the directives with the fluent interface.

How should I approach formatting the table like above?

+1 This would be very useful and the first thing I wanted the library to do.

See 'Table format' in Python's tabulate for examples of what would be great to provide with this library.