ExcelToCsv 0.0.2

dotnet add package ExcelToCsv --version 0.0.2                
NuGet\Install-Package ExcelToCsv -Version 0.0.2                
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="ExcelToCsv" Version="0.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ExcelToCsv --version 0.0.2                
#r "nuget: ExcelToCsv, 0.0.2"                
#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 ExcelToCsv as a Cake Addin
#addin nuget:?package=ExcelToCsv&version=0.0.2

// Install ExcelToCsv as a Cake Tool
#tool nuget:?package=ExcelToCsv&version=0.0.2                

ExcelToCsv

Lightweight library allowing to convert tabular Excel worksheets to csv files.

Complete auto-generated documentation can be found here: sandcastle-documentation.

Example

Below example illustrates the basic usage of the library.

string? targetDirectory = "some-target-directory";
string path = @"ExampleFiles\ExampleExcelFile.xlsx";

ExcelFile.New(path)
    .Do(excel =>
    {
        Console.WriteLine($"Found {excel.Tables.Count()} worksheets:");
        foreach (var table in excel.Tables)
            Console.WriteLine(table);
    })
    .FlatMap(excel =>
    {
        Console.WriteLine("\n\nSaving tables in worksheets as csv.");
        var saveResults = excel.Tables.Select(table =>
        {
            // explicitly:
            var result = excel.SaveAsCsv
            (
                tableIndex: table.Index,
                targetPath: $"{table.Name}.csv",
                delimiter: ","                  // default is comma
            );

            // or in short:
            result = excel.SaveAsCsv(table.Index, $"{table.Name}.csv");

            return result;
        });
        
        Console.WriteLine("\n\nSaving a table with known worksheet name, by cautiously checking its existence.");
        Res resultSingleTable = excel
            .GetTable("Table1")                                                     // Opt<TableInfo>
            .IntoRes("worksheet Table1")                                            // Res<TableInfo>
            .FlatMap(table => excel.SaveAsCsv(table.Index, $"{table.Name}.csv"));   // Res
        
        Console.WriteLine("\n\nSaving a table directly by worksheet name, without checking its existence (errors still handled).");
        Res resultSingleTableDirect = excel.SaveAsCsv("Table1", "Table1-directly.csv");

        Res mergedResult = ReduceResults(saveResults.Reduce(stopAtFirstError: true), resultSingleTable, resultSingleTableDirect);
        return mergedResult;
    })
    .MatchDo
    (
        whenOk: () => Console.WriteLine($"\n\nAll tables successfully saved as csv files in:\n{targetDirectory}"),
        whenErr: err => Console.WriteLine($"\n\nFAILED:\n{err}")
    );
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.0.2 397 1/3/2023
0.0.1 254 12/29/2022