ascii-table
ascii-table copied to clipboard
Custom line/row separator
This is my table format
id column1 column2 column3
---- --------------- ------------------------------ ------------------
1 data11 data12 data13
2 data21 data22 data23
3 data31 data32 data33
4 data41 data42 data43
I need to have empty line between each record to view the data clearly.
So what you want is
id column1 column2 column3
---- --------------- ------------------------------ ------------------
1 data11 data12 data13
2 data21 data22 data23
3 data31 data32 data33
4 data41 data42 data43
?
Yes @freva
It would be even helpful if that is configurable so that line separator can be anything. It would also help to format the span rows.
@sibiarunachalam there are a few ways to achieve this. You can convert the table to rows and then programatically insert empty lines wherever you need them. Another option is to think of the of the empty rows as a row border made out of spaces, e.g.:
String[] headers = {"id", "column1", "column2", "column3"};
String[][] data = {{"1", "data11", "data12", "data13"},
{"2", "data21", "data22", "data23"},
{"3", "data31", "data32", "data33"},
{"4", "data41", "data42", "data43"}};
Character[] style = {null, null, null, null, null, ' ', null, null, '-',
' ', null, null, ' ', null, null, ' ', ' ', null, null, null, null, null, null, null, null, null, null, null, null};
System.out.println(AsciiTable.getTable(style, headers, null, data));
Produces
id column1 column2 column3
---- --------- --------- ---------
1 data11 data12 data13
2 data21 data22 data23
3 data31 data32 data33
4 data41 data42 data43
Thanks @freva for your valuable feedback. Second option will solve the problem in this scenario. Earlier I tried same approach, but it doesn't work in Windows environment whereas it worked in Linux environment. I think I didn't configure the border style properly.