Cayaqui.MPS.ExcelImport 0.2.0

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

Cayaqui.MPS.ExcelImport

Lee .xlsx y materializa DTOs tipados usando los atributos de Cayaqui.MPS.Metadata. Header-name matching con [ImportAlias], fallback por property name, o column-position via [ImportColumn]. Parsing respeta [ImportCulture], [ImportDefault], [ImportTrim], [ImportRegex].

Distribución propietaria — requiere contrato comercial con Cayaqui. Ver LICENSE.txt.

Dependencias: Cayaqui.MPS.Metadata registrado (vía AddMpsExcelImport se registra automáticamente) + licencia Syncfusion válida.

Instalación

dotnet add package Cayaqui.MPS.ExcelImport
builder.Services.AddMpsExcelImport();   // registra también AddMpsMetadata

Uso

public sealed class InvoiceRow
{
    [ImportAlias("N°", "Number")]
    public int InvoiceNumber { get; set; }

    [ImportAlias("Cliente", "Customer Name")]
    [NotEmpty] [MaxLength(100)]
    public string CustomerName { get; set; } = "";

    [ImportCulture("es-CL")]
    public decimal Amount { get; set; }

    [Date("dd/MM/yyyy")]
    public DateTime IssueDate { get; set; }

    [ImportDefault(false)]
    public bool IsPaid { get; set; }

    [ImportIgnore]
    public int InternalId { get; set; }
}
public class ImportService(IExcelImporter<InvoiceRow> importer)
{
    public async Task<ImportSummary> ProcessAsync(Stream xlsx)
    {
        var result = await importer.ImportAsync(xlsx, new ExcelImportOptions
        {
            SheetName = "Invoices",
            HeaderRow = 1,
            ContinueOnRowError = true,
            DefaultCulture = CultureInfo.InvariantCulture
        });

        return new ImportSummary
        {
            Success = result.SuccessCount,
            Failed = result.Errors.Count,
            Items = result.Rows,
            Errors = result.Errors
        };
    }
}

ExcelImportResult

public sealed class ExcelImportResult<T>
{
    IReadOnlyList<T> Rows { get; }                // DTOs exitosamente materializados
    IReadOnlyList<ExcelImportRowError> Errors { get; }
    int TotalRowsRead { get; }
    int SuccessCount { get; }                     // = Rows.Count
    bool HasErrors { get; }
}

public sealed record ExcelImportRowError(
    int RowNumber,
    string PropertyName,
    string? CellValue,
    string Reason);

Reglas de column mapping (precedencia)

  1. [ImportColumn(n)] si está presente → match por posición (1-based).
  2. Si HasHeader = true (default): match por header name:
    • [ImportAlias("A", "B")] primero (ordenado) — case-insensitive por default. Opt-in strict: [ImportAlias("CODE", CaseInsensitive = false)].
    • Luego por [Label("text")] (siempre case-insensitive, fallback conveniente).
    • Finalmente por nombre de la propiedad (siempre case-insensitive).
  3. [ImportIgnore] → propiedad nunca se importa.

Opciones

var opts = new ExcelImportOptions
{
    SheetName = "Data",           // null = primer sheet
    SheetIndex = 1,               // 1-based si no se usa SheetName
    HeaderRow = 1,
    HasHeader = true,
    FirstDataRow = 2,             // null → HeaderRow+1
    LastDataRow = null,           // null → UsedRange.LastRow
    ContinueOnRowError = true,    // agrega a Errors y sigue
    DefaultCulture = CultureInfo.InvariantCulture
};

Requisitos

  • .NET 10.0 o superior
  • Cayaqui.MPS.Metadata registrado
  • Licencia Syncfusion Essential Studio (XlsIO)
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

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.2.0 431 4/24/2026
0.1.1 101 4/24/2026
0.1.0 108 4/24/2026

Initial release. IExcelImporter<T> with header-name + column-position matching, row-level errors, skip-until-header, and Syncfusion XlsIO backend.