tabulate

Tabulate an array of array data with detailed configurations.

This version uses TableConfig and an array of ColumnConfig instead of Config. TableConfig affects the whole table appearance and ColumnConfigs affect each columns' appearance. This can be used if you want to configure (e.g.) columns one-by-one.

Parameters

data T[][]

An array of array data

tableConfig TableConfig

A table-wide configuration

columnConfigs ColumnConfig[]

Configurations for each columns (The length should match with data)

Return Value

Type: string

The table string

Examples

const testdata = [
    ["D-man", "Programming Language"],
    ["D言語くん", "プログラミング言語"],
];
const tableConfig = TableConfig(Style.simple, " ", " ", true);
const columnConfigs = [
    ColumnConfig(20, "マスコットキャラクタ", Align.center),
    ColumnConfig(10, "about", Align.center)
];
const reference =
    " マスコットキャラクタ     about    \n" ~
    "---------------------- ------------\n" ~
    "        D-man           ..ming L.. \n" ~
    "      D言語くん         ..ラミン.. ";
assert(tabulate(testdata, tableConfig, columnConfigs) == reference);

Meta