Imports that survivereal spreadsheets.
User files rarely match your model: the header is on row 3, a column is named differently, a status says Gold where you expect pro. Klyroo.Spreadsheet maps columns and values, validates rows and sends the importable ones to your code.
Install
dotnet add package Klyroo.Spreadsheet --prerelease
Copy the command
Klyroo.Spreadsheet
Header detection Scans the first 20 rows of a sheet and picks the row where most schema columns match, so title rows above the header are skipped.Column matching Compares headers ignoring case, accents, extra spaces and a trailing asterisk, against the column key, its label and its aliases.Typed rules Text, number, date, boolean and select columns, with built-in Email, Pattern, Min, Max and Between rules and custom rules.Review Edits cells, discards and restores rows, and filters the review by tab, severity, issue and text, without touching the source file.
Program.cs
var schema = SpreadsheetSchema.For<PriceRow>(s =>
{
s.Column(r => r.Sku, c => c
.Headers("Item code").Required());
s.Column(r => r.Price, c => c
.Label("Unit price").DecimalSeparator(',')
.Rule(SpreadsheetRule.Min(0m)));
s.Column(r => r.Currency, c => c.Options(
[new(Currency.Eur, "Euro", ["€"]),
new(Currency.Usd, "US dollar", ["$"])]));
s.OnSubmit = SaveAsync;
});
var importer = new SpreadsheetImporter<PriceRow>(schema);
importer.LoadText(text, "prices.csv");
await importer.SubmitAsync(); // InvalidRows hold the restThe header row is found on its own, and a column is matched by its key, its label or an alias: Item code and Unit price land on Sku and Price.
| 1 | Price list 2026 | ||
| 2 | Item codeSku | Unit pricePrice | CurrencyCurrency |
|---|---|---|---|
| 3 | A-1 | 12,50 | € |
| 4 | A-2 | -3 | USD |
| 5 | empty | 9,90 | $ |
| 6 | A-4 | 5,00 | $ |
PriceRow { Sku = "A-1", Price = 12.50m, Currency = Currency.Eur }PriceRow { Sku = "A-4", Price = 5.00m, Currency = Currency.Usd }
Item code is an alias of Sku, and the title row above the header is skipped 12,50 is read with the decimal comma, as a decimal the symbols are aliases of the enum members your code gets typed rows, not text
row 4 Price: Value is below 0row 5 Sku: Required value is missingEverything it does
- Header and sheet detection
- Scans the first 20 rows of a sheet and picks the row where most schema columns match, so title rows above the header are skipped.
- Forgiving column matching
- Compares headers ignoring case, accents, extra spaces, a trailing
*and a trailing(required), against the column key, its label and any aliases you list. - Column suggestions
- When a required column has no match, proposes an unused file column if at least 80% of up to 30 sampled cells parse and pass the rules, and applies it only when you call
AssignColumn. - Typed parsing and rules
- Text, number (either decimal mark), date, boolean and select columns, with built-in
Email,Pattern,Min,MaxandBetweenrules, custom rules and a cross-fieldValidateRowcallback. - Unknown value questions
- Turns select cells that match no option into questions you answer by mapping, leaving empty, skipping the rows or creating the value, or resolves them automatically with a per-column policy.
- Duplicates and existing records
- Detects repeated keys inside the file, keeps the first or last, and marks rows whose key already exists as updates, skips or errors.
- Inline correction
- Edits cells, discards and restores rows, filters the review by tab, severity, issue and text, all without touching the source file.
- 12 languages
- The wizard, its validation messages and its screen reader announcements follow the Klyroo.UI locale (English and French reviewed, ten drafts), and any text can be changed per locale.
- Large files
- Parses a file once and then updates only the rows a change concerns, so editing a cell of a 50,000-row file takes milliseconds, and the wizard pages its review table and caps an import at 10,000 rows by default.
- Saved mappings
- Stores the column mapping and value answers of an import as JSON (source-generated, AOT-safe) and applies them automatically to the next file with the same headers.
- Batched submit with retry
- Sends importable rows to your callback in batches, shows the rows the server refused as errors on those rows, and sends only them again.
Packages
-
The import engine: parsing, matching, validation and submit. No UI dependency.
Klyroo.BlazorSpreadsheet TheKlySpreadsheetwizard for Blazor and .NET MAUI Blazor Hybrid, built on Klyroo.UI. Includes the Core package.Import
Install it, then open the first page.
Change here for the other lines
- Klyroo.UI Accessible Blazor components for the web and .NET MAUI Blazor Hybrid, styled with Tailwind CSS v4
- Klyroo.Query Typed query model, URL state sync, and IQueryable / EF Core execution
- Klyroo.Table Data lists with table and card-grid layouts, filters, selection and actions
- Klyroo.Form Schema-driven forms, validation and wizards
- Klyroo.Dashboard Dashboard controller, filters and Blazor blocks: stats, gauges, charts, tables and feeds
- Klyroo.Display Code highlighting, secret and file list components, media player controls and file preview
- Klyroo.Spreadsheet Import wizard for CSV, TSV, Excel and pasted data, with column and value mapping
- Klyroo.Agent Bridge that lets AI agents read and act on Klyroo forms, dashboards and imports
- Klyroo.Hotkey Server-side .NET client for Hotkey cloud browsers, human handoffs and signed webhooks
- Klyroo.Stack
Meta-package, MCP documentation server and
dotnet newtemplates