SharpTables 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SharpTables --version 1.0.0                
NuGet\Install-Package SharpTables -Version 1.0.0                
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="SharpTables" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharpTables --version 1.0.0                
#r "nuget: SharpTables, 1.0.0"                
#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 SharpTables as a Cake Addin
#addin nuget:?package=SharpTables&version=1.0.0

// Install SharpTables as a Cake Tool
#tool nuget:?package=SharpTables&version=1.0.0                

SharpTables

A versatile and customizable console table formatter. Generate tables ready to be written to console with the ability to customize even the characters used by the generator to generate the table.

Example usage

Basic table

Formatting f = Formatting.Minimalist;

object[,] dataset = new object[,]
{
	{ "Name", "Age", "City" },
	{ "John Doe", 42, "New York" },
	{ "Jane Doe", 36, "Chicago" },
	{ "Joe Bloggs", 25, "Los Angeles" },
	{ "Jenny Smith", 28, "Miami" }
};

Table table = Table.FromDataSet(dataset, f); // Also supports IEnumerable<IEnumerable<T>>

// You may also add rows manually!
table.AddRow(new Row(["Jimmy Jones", null, "Las Vegas"])); // Supports nullables

table.SetColumnColor(1, ConsoleColor.Yellow);
table.EmptyReplacement = "N/A"; // Replacement for null or empty strings
table.SetColumnPadding(1, 5, true);
table.Print();
Console.WriteLine();

/*
 Name             Age      City
────────────────────────────────────────────
 John Doe         42       New York

 Jane Doe         36       Chicago

 Joe Bloggs       25       Los Angeles

 Jenny Smith      28       Miami

 Jimmy Jones      N/A      Las Vegas
*/

Custom Formatting

The Formatting class already has some presets, you can also modify them using with due to them being record types, or make your own instance. By default, using new Formatting() will use Formatting.Default


// Using the power of records!
Formatting format = Formatting.ASCII with 
{ 
	DividerColor = ConsoleColor.DarkGray,
	BottomLeftDivider = '@',
	BottomRightDivider = '@',
	TopLeftDivider = '@',
	TopRightDivider = '@',
	MiddleDivider = '%',
	Header = Formatting.ASCII.Header with { Separated = true, }
};
/*
+----------------+--------+----------------+
|Name            |Age     |City            |
+----------------+--------+----------------+
@----------------+--------+----------------@
|John Doe        |42      |New York        |
+----------------%--------%----------------+
|Jane Doe        |36      |Chicago         |
+----------------%--------%----------------+
|Joe Bloggs      |25      |Los Angeles     |
+----------------%--------%----------------+
|Jenny Smith     |28      |Miami           |
+----------------%--------%----------------+
|Jimmy Jones     |N/A     |Las Vegas       |
@----------------+--------+----------------@
*/

Contributing

If you found a bug, have any questions, want to implement your own additions or contribute in any other way, feel free to open a pull request!

License

This project is licensed under the MIT License

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.5.0 130 8/10/2024
1.4.0 128 7/21/2024
1.3.0 112 7/11/2024
1.2.1 107 7/5/2024
1.2.0 98 7/4/2024
1.1.0 137 6/28/2024
1.0.0 108 6/27/2024