![]() |
VOOZH | about |
dotnet add package Cayaqui.ExcelImport --version 0.3.8
NuGet\Install-Package Cayaqui.ExcelImport -Version 0.3.8
<PackageReference Include="Cayaqui.ExcelImport" Version="0.3.8" />
<PackageVersion Include="Cayaqui.ExcelImport" Version="0.3.8" />Directory.Packages.props
<PackageReference Include="Cayaqui.ExcelImport" />Project file
paket add Cayaqui.ExcelImport --version 0.3.8
#r "nuget: Cayaqui.ExcelImport, 0.3.8"
#:package Cayaqui.ExcelImport@0.3.8
#addin nuget:?package=Cayaqui.ExcelImport&version=0.3.8Install as a Cake Addin
#tool nuget:?package=Cayaqui.ExcelImport&version=0.3.8Install as a Cake Tool
Lee .xlsx y materializa DTOs tipados usando los atributos de Cayaqui.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.Metadataregistrado (víaAddCayaquiExcelImportse registra automáticamente) + licencia Syncfusion válida.
dotnet add package Cayaqui.ExcelImport
builder.Services.AddCayaquiExcelImport(); // registra también AddCayaquiMetadata
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
};
}
}
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);
[ImportColumn(n)] si está presente → match por posición (1-based).HasHeader = true (default): match por header name:
[ImportAlias("A", "B")] primero (ordenado) — case-insensitive por default.
Opt-in strict: [ImportAlias("CODE", CaseInsensitive = false)].[Label("text")] (siempre case-insensitive, fallback conveniente).[ImportIgnore] → propiedad nunca se importa.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
};
Cayaqui.Metadata registrado| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
0.2.1 — Rebuild contra Cayaqui.Metadata 0.20.0 (refactor de namespaces: tipos movidos a Cayaqui.Metadata.Attributes/.Resolver/.Models/.Branding). Sin cambios de API propios; corrige TypeLoadException/CS7069 al consumir este paquete junto a Metadata 0.20.0.
Initial release. IExcelImporter<T> with header-name + column-position matching, row-level errors, skip-until-header, and Syncfusion XlsIO backend.