https://github.com/soenneker/soenneker.blazor.sheetmapper
A Blazor component and utility library for mapping uploaded CSV or tabular files to C# objects. Supports header extraction and user-defined property mapping.
https://github.com/soenneker/soenneker.blazor.sheetmapper
blazor blazorlibrary blazorsheetmapper csharp csv dotnet excel mapper sheet sheetmapper
Last synced: 12 days ago
JSON representation
A Blazor component and utility library for mapping uploaded CSV or tabular files to C# objects. Supports header extraction and user-defined property mapping.
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.blazor.sheetmapper
- Owner: soenneker
- License: mit
- Created: 2025-05-28T00:21:16.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2026-03-07T15:48:47.000Z (19 days ago)
- Last Synced: 2026-03-07T21:55:36.378Z (19 days ago)
- Topics: blazor, blazorlibrary, blazorsheetmapper, csharp, csv, dotnet, excel, mapper, sheet, sheetmapper
- Language: HTML
- Homepage: https://soenneker.com
- Size: 638 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/soenneker.blazor.sheetmapper/)
[](https://github.com/soenneker/soenneker.blazor.sheetmapper/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/soenneker.blazor.sheetmapper/)
[](https://github.com/soenneker/soenneker.blazor.sheetmapper/actions/workflows/codeql.yml)
# Soenneker.Blazor.SheetMapper
A Blazor component and utility library for mapping CSV or tabular files to C# objects.

Leverage [FilePond](https://github.com/soenneker/soenneker.blazor.filepond) for uploads and [TomSelect](https://github.com/soenneker/soenneker.blazor.tomselect) for interactive dropdowns. Automatically extract headers, map columns to your model, and retrieve a clean `{ property ? column }` map.
[Demo](https://soenneker.github.io/soenneker.blazor.sheetmapper)
## Features
* **Header extraction** from CSV or tab-delimited files
* **Interactive mapping** of columns to model properties
* **Automatic heuristic mapping** (case- and whitespace-insensitive)
* **Status icons** for *unmapped*, *duplicate*, and *mapped* states
* **Show/hide** the status-icon column on demand
* **API** to fetch the final mapping as `Dictionary`
---
## Installation
```bash
dotnet add package Soenneker.Blazor.SheetMapper
```
---
## Setup
1. **Register interop** in your DI container (e.g., `Program.cs`):
```csharp
builder.Services.AddSheetMapperAsScoped();
```
2. **Import namespace** in your `_Imports.razor` or component:
```razor
@using Soenneker.Blazor.SheetMapper
```
---
## Basic Usage
```razor
@page "/import"
@inject ISheetMapperInterop SheetMapperInterop
Get Mapping
@code {
private SheetMapper? sheetMapper;
private void ShowMap()
{
if (sheetMapper is not null)
{
var map = sheetMapper.GetCurrentMap();
// map: property ? CSV column
}
}
}
```
---
## Component Parameters
| Parameter | Type | Default | Description |
| ------------------ | ---------------- | ------- | -------------------------------------------------------------- |
| `TargetType` | `Type` | � | **Required.** Model type whose writable properties are mapped. |
| `AutomaticallyMap` | `bool` | `false` | Run auto-mapping heuristic on file load. |
| `ShowStatusIcons` | `bool` | `true` | Toggle visibility of the status-icon column. |
| `NotMappedIcon` | `RenderFragment` | ?? | Icon/markup for unmapped state. |
| `DuplicatedIcon` | `RenderFragment` | ?? | Icon/markup for duplicate-mapping state. |
| `MappedIcon` | `RenderFragment` | ? | Icon/markup for successful mapping. |
---
## Public API
* `void AutoMap()`
Re-run the auto-mapping logic at any time.
* `Dictionary GetCurrentMap()`
Returns `{ property ? selected column }`. Unmapped properties return `""`.
---
## Customization
### Status Icons
Override the built-in emojis with your own markup (SVG, ``, etc.):
```razor
```
### Show/Hide Icon Column
Use the `ShowStatusIcons` parameter to toggle the entire status-icon column:
```razor
```
---
## Styling
* **CSS classes** for fine-tuning:
* `.map-row` � wrapper for each mapping row
* `.status-icon` � container for the icon
Override or extend them to match your design system.