IntNovAction.Utils.ExcelImporter 2.1.1

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

// Install IntNovAction.Utils.ExcelImporter as a Cake Tool
#tool nuget:?package=IntNovAction.Utils.ExcelImporter&version=2.1.1                

IntNovAction.Utils.ExcelImporter

Utility to import excel data into POCOs

The usage is quite simple:


// Define the destination POCO class

class SampleImportInto
{
    public int IntColumn { get; set; }
    public int? NullableIntColumn { get; set; }
    public decimal DecimalColumn { get; set; }
    public decimal? NullableDecimalColumn { get; set; }
    public float FloatColumn { get; set; }
    public float? NullableFloatColumn { get; set; }
    public string StringColumn { get; set; } 
    public DateTime DateColumn { get; set; }
    public DateTime? NullableDateColumn { get; set; }
    public bool BooleanColumn { get; set; }
    public bool? NullableBooleanColumn { get; set; }
}


// Read the excel file 
using (var stream = File.OpenRead("d:\\ExcelWithData.xlsx"))
{
    // Create the typed importer
    var importer = new Importer<SampleImportInto>();

    // Configure
    importer
        .SetErrorStrategy(ErrorStrategy.AddElement)
        .FromExcel(stream, "Sheet Name")
        .For(p => p.IntColumn, "Int Column")
        .For(p => p.FloatColumn, "Float Column")
        .For(p => p.DecimalColumn, "Decimal Column")
        .For(p => p.NullableIntColumn, "Nullable Int Column")
        .For(p => p.NullableFloatColumn, "Nullable Float Column")
        .For(p => p.NullableDecimalColumn, "Nullable Decimal Column")
        .For(p => p.StringColumn, "String Column")
        .For(p => p.DateColumn, "Date Column")
        .For(p => p.NullableDateColumn, "Nullable Date Column")
        .For(p => p.BooleanColumn, "Boolean Column")
        .For(p => p.NullableBooleanColumn, "Nullable Boolean Column");

    // Import
    var importResults = importer.Import();
    
    // Read the imported objects...
    var numImportedItems = importResults.ImportedItems.Count();

    // Check the errors...
	var numImportedObjects = importResults.Errors.Count();
}

It supports nested objects also (1-1 relationships), but the default constructor must create the nested objects.

It also allows to generate an Excel file with the exact format to import the data, very useful as a template

	var importer = new Importer<SampleImportInto>();

    // Configure
    importer
        .For(p => p.IntColumn, "Int Column")
        .For(p => p.FloatColumn, "Float Column")
        .For(p => p.DecimalColumn, "Decimal Column")
        .For(p => p.NullableIntColumn, "Nullable Int Column")
        .For(p => p.NullableFloatColumn, "Nullable Float Column")
        .For(p => p.NullableDecimalColumn, "Nullable Decimal Column")
        .For(p => p.StringColumn, "String Column")
        .For(p => p.DateColumn, "Date Column")
        .For(p => p.NullableDateColumn, "Nullable Date Column")
        .For(p => p.BooleanColumn, "Boolean Column")
        .For(p => p.NullableBooleanColumn, "Nullable Boolean Column");

	using (var excelStream = importer.GenerateExcel())
    {
		// Do stuff with the excel
	}

You can also generate the Excel file template with sample rows

    
    // sampleData contains a List<SampleImportInto>
	using (var excelStream = importer.GenerateExcel(sampleData))
    {
		// Do stuff with the excel
	}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.1.1 1,444 6/24/2022
2.1.0 470 6/24/2022
2.0.0 437 8/25/2021
0.0.7 1,623 3/12/2019
0.0.6 723 12/29/2018
0.0.5 801 9/24/2018
0.0.4 829 9/17/2018
0.0.3 818 9/17/2018
0.0.2 816 9/14/2018
0.0.1 816 9/14/2018

Changes in namespaces, Now you can specify the initial coordinates for the importation