Tuesday 13 July 2021

AsciiTable: span columns

Example 1: Span 4 columns

asciiTable.addRow("row 2 col 1", null, null, null, "Span 4 columns");

 

Example 2: Span first 2 columns and last 3 columns

asciiTable.addRow(null, "Span 2 columns", null, null, "Span 3 columns");

 

Example 3: Span all the 5 columns.

asciiTable.addRow(null, null, null, null, "Span 5 columns");

 

Find the below working application.

 

ColumnSpanDemo.java

package com.sample.app;

import de.vandermeer.asciitable.AsciiTable;

public class ColumnSpanDemo {

	public static void main(String args[]) {
		AsciiTable asciiTable = new AsciiTable();

		asciiTable.addRule();
		asciiTable.addRow("row 1 col 1", "row 1 col 2", "row 1 col 3", "row 1 col 4", "row 1 col 5");

		asciiTable.addRule();
		asciiTable.addRow("row 2 col 1", null, null, null, "Span 4 columns");

		asciiTable.addRule();
		asciiTable.addRow(null, "Span 2 columns", null, null, "Span 3 columns");

		asciiTable.addRule();
		asciiTable.addRow(null, null, null, null, "Span 5 columns");
		asciiTable.addRule();

		String rend = asciiTable.render();

		System.out.println(rend);

	}

}

 

Output


 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment