Snork.AsciiTable
1.1.1550
dotnet add package Snork.AsciiTable --version 1.1.1550
NuGet\Install-Package Snork.AsciiTable -Version 1.1.1550
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Snork.AsciiTable" Version="1.1.1550" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Snork.AsciiTable --version 1.1.1550
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Snork.AsciiTable, 1.1.1550"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Snork.AsciiTable as a Cake Addin #addin nuget:?package=Snork.AsciiTable&version=1.1.1550 // Install Snork.AsciiTable as a Cake Tool #tool nuget:?package=Snork.AsciiTable&version=1.1.1550
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Ascii Table Generator
This library generates tables in Ascii from raw data, enumerables, and instances of System.Data.DataTable. Within cells, it has text wrapping capability based on this author's Snork.TextWrap library.
Table of Contents
<a name="example-1">Example 1 - Populate table in code</a>
var table = new AsciiTableGenerator("A Title");
table.SetHeading("", "Name", "Age");
table.Add(1, "Bob", 52).Add(2, "John", 34).Add(3, "Jim", 83);
Console.Write(table.ToString());
Example 1 output:
.----------------.
| A Title |
|----------------|
| | Name | Age |
|---|------|-----|
| 1 | Bob | 52 |
| 2 | John | 34 |
| 3 | Jim | 83 |
'----------------'
<a name="example-2">Example 2 - Populate table from enumerable</a>
class MyClass {
public string Column1 { get; set; }
public string Column2 { get; set; }
}
var items = new List<MyClass>
{
new MyClass { Column1 = "Bozo", Column2 = "TheClown" },
new MyClass { Column1 = "Popeye", Column2 = "TheSailor" }
};
var table = AsciiTableGenerator.FromEnumerable(items);
Console.Write(table.ToString());
Example 2 Output:
.---------------------.
| Column1 | Column2 |
|---------|-----------|
| Bozo | TheClown |
| Popeye | TheSailor |
'---------------------'
<a name="api">API</a>
public class Snork.AsciiTable.AsciiTableGenerator
Properties
Type | Name | Summary |
---|---|---|
Options |
Options |
Methods
Return Type | Name | Summary |
---|---|---|
AsciiTableGenerator |
Add(IEnumerable<Object> row) |
Add a row of data |
AsciiTableGenerator |
Add(Object[] row) |
Add a row of data |
AsciiTableGenerator |
AddRange(IEnumerable<List<Object>> rows) |
Add a range of rows |
AsciiTableGenerator |
Clear() | Clear current table data and reset settings to defaults |
AsciiTableGenerator |
ClearRows() | Clear current table data |
AsciiTableGenerator |
DisplayBorder(Boolean value) |
Setting for whether or not to display the border around the cells |
AsciiTableGenerator |
DisplayRowSeparators(Boolean value) |
Display row separators between each row of data, for improved visibility |
List<String> |
GetCaptions() | Get list of captions for all columns |
List<List<Object>> |
GetRows() | Get current table data as list of list |
String |
GetTitle() | Get the current title |
AsciiTableGenerator |
SetBorder(Nullable<Char> horizontalEdge = null, Nullable<Char> verticalEdge = null, Nullable<Char> topCorner = null, Nullable<Char> bottomCorner = null) |
Set the border characters for rendering, if no arguments are passed it will be reset to defaults. If a single edge arg is passed, it will be used for all borders. |
AsciiTableGenerator |
SetCaptionAlignment(Int32 index, CellAlignmentEnum alignment) |
Set the alignment of caption for a given column |
AsciiTableGenerator |
SetCaptions(List<String> captions) |
Set captions for all columns |
AsciiTableGenerator |
SetCaptions(String[] captions) |
Set captions for all columns |
AsciiTableGenerator |
SetCellAlignment(Int32 index, CellAlignmentEnum cellAlignment) |
Set alignment for cells in a given column |
AsciiTableGenerator |
SetColumnWidth(Int32 index, ColumnWidthTypeEnum columnWidthType, Nullable<Int32> width = null) |
Set width for a given column, by index. ColumnWidthType can be Fixed or Auto |
AsciiTableGenerator |
SetDisplayCaptions(Boolean value) |
Setting for whether captions are displayed or not |
AsciiTableGenerator |
SetTextWrapperOptions(Int32 index, Action<TextWrapperOptions> action) |
Set text wrapping options for a particular column with options from [Snork.TextWrap library] (https://github.com/xavierjefferson/Snork.TextWrap) |
AsciiTableGenerator |
SetTitle(String name) |
Set title for the table. Will be rendered in single cell that spans all columns |
AsciiTableGenerator |
SetTitleAlignment(CellAlignmentEnum alignment) |
Set alignment for title cell |
String |
ToString() | Render the table |
Static Methods
Return Type | Name | Summary |
---|---|---|
AsciiTableGenerator |
FromDataTable(DataTable table, Options options = null, Boolean autoCaptions = True) |
Create an AsciiTableGenerator instance with a datatable as its source |
AsciiTableGenerator |
FromEnumerable(IEnumerable<T> data, Options options = null, Boolean autoCaptions = True) |
Create an AsciiTableGenerator instance with an enumerable of some type as its source |
CellAlignmentEnum
public enum Snork.AsciiTable.CellAlignmentEnum
: Enum, IComparable, IFormattable, IConvertible
Enum
Value | Name | Summary |
---|---|---|
0 |
NotSpecified | |
1 |
Left | |
2 |
Right | |
3 |
Center |
ColumnWidthTypeEnum
public enum Snork.AsciiTable.ColumnWidthTypeEnum
: Enum, IComparable, IFormattable, IConvertible
Enum
Value | Name | Summary |
---|---|---|
0 |
Auto | |
1 |
Fixed |
Options
public class Snork.AsciiTable.Options
Properties
Type | Name | Summary |
---|---|---|
Char |
BottomCorner | |
CellAlignmentEnum |
CaptionCellAlignment | Cell alignment for captions |
Boolean |
DisplayBorder | Show border around table |
Boolean |
DisplayCaptions | Show captions with a row separator |
Boolean |
DisplayRowSeparators | Add row separators between each row of data |
Char |
HorizontalEdge | |
String |
LinePrefix | Prefix to add to each line on render |
String |
Title | Table title. Defaults to null |
CellAlignmentEnum |
TitleCellAlignment | Cell alignment for title, if set |
Char |
TopCorner | |
Char |
VerticalEdge |
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- snork.textwrap (>= 1.0.1301)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Turn on text wrapping for captions