You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@ This library aims to provide helpers for creating tabular data with minimal fuss
4
4
5
5
Easily create *tab* or *comma* separated values (via `CsvDefinition`), or padded and aligned columns of plain text (with `PlainTextTable`).
6
6
7
-
This library is available on [NuGet](https://www.nuget.org/packages/csharpvitamins.tabulation/). To install, run the following command in the Package Manager Console:
7
+
Available on [NuGet](https://www.nuget.org/packages/csharpvitamins.tabulation/). To install, run the following command in the Package Manager Console:
8
8
9
9
PM> Install-Package CSharpVitamins.Tabulation
10
10
11
11
12
12
13
13
## Usage: `CsvDefinition`
14
14
15
-
`CsvDefinition` is designed for quick production of CSV style text - it aims to keep the column header and *how* to produce the value close together.
15
+
`CsvDefinition` is designed for quick production of CSV style text - it aims to keep the *column header* and *how* to produce the value close together.
16
16
17
17
// vars to be used inside column value funcs
18
18
const decimal VIP_SPEND = 1000000M;
@@ -58,15 +58,14 @@ At its heart, `CsvDefinition<T>` is a wrapper around `List<KeyValuePair<string,
58
58
fields.Remove("Spend $");
59
59
60
60
61
-
#### Create from a class
61
+
**Or have the definition created for you, from a class**
62
62
63
-
You can also create a a definition from a model/class
64
63
65
64
var fields = new CsvDefinitionFactory().CreateFromModel<MyEntity>();
66
65
67
66
... get data, create writer, etc...
68
67
69
-
fields.Write(writer, rows, "\t");
68
+
fields.Write(writer, rows, ",");
70
69
71
70
If you want more control over the production of the results, you can specify `Func<PropertyInfo, object, string>` converters for the type.
72
71
@@ -87,7 +86,12 @@ If you want more control over the production of the results, you can specify `Fu
87
86
88
87
## Usage: `PlainTextTable`
89
88
90
-
A `PlainTextTable` allows padding of tabular data so it can be displayed easily as text.
89
+
A `PlainTextTable` allows padding of tabular data so it can be displayed easily as text.
90
+
91
+
* Works best with small to medium length strings of data
92
+
* Does not support *multi-line text* (newlines) or *tabs*
93
+
* Since columns are padded using spaces, output from this class is best presented using a **fixed-wdith font**
94
+
91
95
92
96
#### Example 1: classic
93
97
@@ -107,9 +111,9 @@ A `PlainTextTable` allows padding of tabular data so it can be displayed easily
107
111
108
112
which might return
109
113
110
-
Name Enabled? Job
111
-
Dave Y Developer
112
-
Sarah Y Designer
114
+
Name Enabled? Job
115
+
Dave Y Developer
116
+
Sarah Y Designer
113
117
Mustafa N Data Analysis
114
118
115
119
@@ -133,6 +137,5 @@ which might produce something like this
0 commit comments