LeandroAlves.ConsoleGrid
1.2.0
dotnet add package LeandroAlves.ConsoleGrid --version 1.2.0
NuGet\Install-Package LeandroAlves.ConsoleGrid -Version 1.2.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="LeandroAlves.ConsoleGrid" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LeandroAlves.ConsoleGrid" Version="1.2.0" />
<PackageReference Include="LeandroAlves.ConsoleGrid" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LeandroAlves.ConsoleGrid --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LeandroAlves.ConsoleGrid, 1.2.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.
#:package LeandroAlves.ConsoleGrid@1.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LeandroAlves.ConsoleGrid&version=1.2.0
#tool nuget:?package=LeandroAlves.ConsoleGrid&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Console Grid
O objetivo deste projeto é simular uma grid de visualização simples utilizando aplicativo console.
Tecnologia Utilizadas
- .Net 6
- Linq
Como instalar:
> dotnet add package LeandroAlves.ConsoleGrid
Exemplo:
var produtos = new List<Produto>();
produtos.Add(new Produto(1, "Arroz", 20.35m, DateTime.Now));
produtos.Add(new Produto(2, "Feijao", 12.0m, DateTime.Now));
produtos.Add(new Produto(3, "Oleo", 14.16m, DateTime.Now));
produtos.Add(new Produto(4, "Ovo 30un", 18.0m, DateTime.Now));
var grid = new Grid("lista de produtos", 4, 20, 10, 11);
grid.ColumnsName("Id", "Descricao", "Valor", "Data");
grid.ColumnsFormat(string.Empty, string.Empty, "{0:c2}", "{0:dd/MM/yyyy}");
grid.ColumnsAlign(Align.RIGHT, Align.LEFT, Align.RIGHT, Align.RIGHT);
grid.DataSource(produtos);
grid.Footer("Total: " + produtos.Sum(p => p.Valor).ToString("c2"));
grid.Print();
-----------------------------------------------------------
| LISTA DE PRODUTOS |
-----------------------------------------------------------
| Id | Descricao | Valor | Data |
-----------------------------------------------------------
| 1 | Arroz | R$ 20,35 | 08/06/2022 |
-----------------------------------------------------------
| 2 | Feijao | R$ 12,00 | 08/06/2022 |
-----------------------------------------------------------
| 3 | Oleo | R$ 14,16 | 08/06/2022 |
-----------------------------------------------------------
| 4 | Ovo 30un | R$ 18,00 | 08/06/2022 |
-----------------------------------------------------------
| Total: R$ 64,51 |
-----------------------------------------------------------
Exemplo de rodapé utilizando colunas
var col1 = "Qtde: " + produtos.Count;
var col2 = "Total: " + produtos.Sum(p => p.Valor).ToString("c2");
var col3 = "Média: " + produtos.Average(p => p.Valor).ToString("c2");
grid.Footer(col1, col2, col3);
grid.Print();
-----------------------------------------------------------
| LISTA DE PRODUTOS |
-----------------------------------------------------------
| Id | Descricao | Valor | Data |
-----------------------------------------------------------
| 1 | Arroz | R$ 20,35 | 05/06/2022 |
-----------------------------------------------------------
| 2 | Feijao | R$ 12,00 | 05/06/2022 |
-----------------------------------------------------------
| 3 | Oleo | R$ 14,16 | 05/06/2022 |
-----------------------------------------------------------
| 4 | Ovo 30un | R$ 18,00 | 05/06/2022 |
-----------------------------------------------------------
| Qtde: 4 | Total: R$ 64,51 | Média: R$ 16,13 |
-----------------------------------------------------------
Exemplo de rodapé com colunas e alinhamento
var col1 = "Qtde: " + produtos.Count;
var col2 = "Total: " + produtos.Sum(p => p.Valor).ToString("c2");
grid.FooterAlign(Align.LEFT, Align.RIGHT);
grid.Footer(col1, col2);
grid.Print();
-----------------------------------------------------------
| LISTA DE PRODUTOS |
-----------------------------------------------------------
| Id | Descricao | Valor | Data |
-----------------------------------------------------------
| 1 | Arroz | R$ 20,35 | 08/06/2022 |
-----------------------------------------------------------
| 2 | Feijao | R$ 12,00 | 08/06/2022 |
-----------------------------------------------------------
| 3 | Oleo | R$ 14,16 | 08/06/2022 |
-----------------------------------------------------------
| 4 | Ovo 30un | R$ 18,00 | 08/06/2022 |
-----------------------------------------------------------
| Qtde: 4 | Total: R$ 64,51 |
-----------------------------------------------------------
Autores
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.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.