CsvWriter 1.0.10

dotnet add package CsvWriter --version 1.0.10
                    
NuGet\Install-Package CsvWriter -Version 1.0.10
                    
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="CsvWriter" Version="1.0.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CsvWriter" Version="1.0.10" />
                    
Directory.Packages.props
<PackageReference Include="CsvWriter" />
                    
Project file
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 CsvWriter --version 1.0.10
                    
#r "nuget: CsvWriter, 1.0.10"
                    
#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 CsvWriter@1.0.10
                    
#: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=CsvWriter&version=1.0.10
                    
Install as a Cake Addin
#tool nuget:?package=CsvWriter&version=1.0.10
                    
Install as a Cake Tool

CsvWriter

CsvWriter is a simple tool for writing data to CSV files.

Features

  • Write data in CSV format.
  • Support for different delimiters.
  • Support for different encodings.
  • Support for ZIP compression.
  • Support for formatting data.
  • Easy to use and integrate into other projects.

Installation

Para instalar o CsvWriter, você pode clonar o repositório diretamente do GitHub:

git clone https://github.com/seu-usuario/CsvWriter.git

Usage

Here is a basic example of how to use CsvWriter to create a CSV file in MemoryStream:

public class Order
{
    [Name("ID")] 
    public string Id { get; set; }

    [Name("Date of Order")]
    [Format(FormatColumn.LongDate)]
    public DateTime Date { get; set; }

    [Name("Quantity")] 
    public int Quantity { get; set; }

    [Name("ID")]
    [Format(FormatColumn.Decimal)]
    public decimal Amount { get; set; }

    [Name("Total")]
    [Format(FormatColumn.Currency)]
    public decimal Total { get; set; }

    [Name("Customer")] 
    public string Customer { get; set; }

    [Name("IsShipping")] 
    public bool IsShipping { get; set; }
}
using System;
using System.Collections.Generic;
using CsvWriterLib;

class Program
{
    static void Main()
    {
        var listaEmissores = new List<Order>
        {
            new Order
            {
                Id = Guid.NewGuid().ToString(),
                Date = DateTime.Now,
                Quantity = 1,
                IsShipping = true,
                Amount = 100.00m,
                Total = 100.00m,
                Customer = "Customer 1"
            },
            new Order
            {
                Id = Guid.NewGuid().ToString(),
                IsShipping = true,
                Date = DateTime.Now,
                Quantity = 2,
                Amount = 200.00m,
                Total = 400.00m,
                Customer = "Customer 2"
            },
            new Order
            {
                Id = Guid.NewGuid().ToString(),
                IsShipping = false,
                Date = DateTime.Now,
                Quantity = 3,
                Amount = 300.00m,
                Total = 900.00m,
                Customer = "Customer 3"
            }
        };

        var options = new CsvWriterOptions
        {
            Delimiter = ";",
            CultureInfo = CultureInfo.GetCultureInfo("pt-BR"),
            Encoding = new UTF8Encoding(false)
        };

        var csvWriter = new Writer();
        MemoryStream csv = await csvWriter.CreateFileAsMemoryStream(listaEmissores, options);
    }
}

Here is a basic example of how to use CsvWriter to create a ZIP-compressed CSV file with output in MemoryStream:

using System;
using System.Collections.Generic;
using CsvWriterLib;

class Program
{
    static void Main()
    {
        var listaEmissores = new List<Order>
        {   
            new Order
            {
                Id = Guid.NewGuid().ToString(),
                Date = DateTime.Now,
                Quantity = 1,
                IsShipping = true,
                Amount = 100.00m,
                Total = 100.00m,
                Customer = "Customer 1"
            },
            new Order
            {
                Id = Guid.NewGuid().ToString(),
                IsShipping = true,
                Date = DateTime.Now,
                Quantity = 2,
                Amount = 200.00m,
                Total = 400.00m,
                Customer = "Customer 2"
            },
            new Order
            {
                Id = Guid.NewGuid().ToString(),
                IsShipping = false,
                Date = DateTime.Now,
                Quantity = 3,
                Amount = 300.00m,
                Total = 900.00m,
                Customer = "Customer 3"
            }
        };

        var options = new CsvWriterOptions
        {
            Delimiter = ";",
            CultureInfo = CultureInfo.GetCultureInfo("pt-BR"),
            Encoding = Encoding.UTF8
        };

        var name = "OrderReport";
        var csv = new Writer();
        MemoryStream relatorio = await csv.CreateCompressedFileAsMemoryStream(data, name, new UTF8Encoding(false));
    }
}

Contribution

Contributions are welcome! Feel free to open issues and pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

CsvWriter is a simple tool for writing data to CSV files.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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 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.  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.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • 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.0.10 1,209 9/20/2024
1.0.9 116 9/20/2024
1.0.8 101 9/19/2024
1.0.7 95 9/19/2024
1.0.6 100 9/19/2024
1.0.5 96 9/19/2024
1.0.4 110 9/19/2024
1.0.3 104 9/19/2024