@@ -59,8 +59,8 @@ Set column widths and alignments
5959 header = [" #" , " G" , " H" , " R" , " S" ],
6060 body = [[" 1" , " 30" , " 40" , " 35" , " 30" ], [" 2" , " 30" , " 40" , " 35" , " 30" ]],
6161 first_col_heading = True ,
62- column_widths = [5 ] * 5 , # [ 5, 5, 5, 5, 5]
63- alignments = [Alignment.LEFT ] + [Alignment.RIGHT ] * 4 , # First is left, remaining 4 are right
62+ column_widths = [5 , 5 , 5 , 5 , 5 ],
63+ alignments = [Alignment.LEFT ] + [Alignment.RIGHT ] * 4 ,
6464 )
6565
6666 print (output)
@@ -84,7 +84,7 @@ Use a preset style
8484 output = table2ascii(
8585 header = [" First" , " Second" , " Third" , " Fourth" ],
8686 body = [[" 10" , " 30" , " 40" , " 35" ], [" 20" , " 10" , " 20" , " 5" ]],
87- column_widths = [10 ] * 4 ,
87+ column_widths = [10 , 10 , 10 , 10 ] ,
8888 style = PresetStyle.ascii_box
8989 )
9090
@@ -130,7 +130,7 @@ Check :ref:`TableStyle` for more info.
130130 output = table2ascii(
131131 header = [" First" , " Second" , " Third" ],
132132 body = [[" 10" , " 30" , " 40" ], [" 20" , " 10" , " 20" ], [" 30" , " 20" , " 30" ]],
133- style = my_style
133+ style = my_style,
134134 )
135135
136136 print (output)
@@ -143,4 +143,41 @@ Check :ref:`TableStyle` for more info.
143143 | 20 : 10 : 20 |
144144 | 30 : 20 : 30 |
145145 *-------'--------'-------*
146- """
146+ """
147+
148+ Merge adjacent cells
149+ ~~~~~~~~~~~~~~~~~~~~
150+
151+ Check :ref: `Merge ` for more info.
152+
153+ .. code :: py
154+
155+ from table2ascii import table2ascii, Merge, PresetStyle
156+
157+ output = table2ascii(
158+ header = [" #" , " G" , " Merge" , Merge.LEFT , " S" ],
159+ body = [
160+ [1 , 5 , 6 , 200 , Merge.LEFT ],
161+ [2 , " E" , " Long cell" , Merge.LEFT , Merge.LEFT ],
162+ [" Bonus" , Merge.LEFT , Merge.LEFT , " F" , " G" ],
163+ ],
164+ footer = [" SUM" , " 100" , " 200" , Merge.LEFT , " 300" ],
165+ style = PresetStyle.double_thin_box,
166+ first_col_heading = True ,
167+ )
168+
169+ print (output)
170+
171+ """
172+ ╔═════╦═════╤═══════╤═════╗
173+ ║ # ║ G │ Merge │ S ║
174+ ╠═════╬═════╪═══╤═══╧═════╣
175+ ║ 1 ║ 5 │ 6 │ 200 ║
176+ ╟─────╫─────┼───┴─────────╢
177+ ║ 2 ║ E │ Long cell ║
178+ ╟─────╨─────┴───┬───┬─────╢
179+ ║ Bonus │ F │ G ║
180+ ╠═════╦═════╤═══╧═══╪═════╣
181+ ║ SUM ║ 100 │ 200 │ 300 ║
182+ ╚═════╩═════╧═══════╧═════╝
183+ """
0 commit comments