# ExcelMapper **Repository Path**: JieBlog/ExcelMapper ## Basic Information - **Project Name**: ExcelMapper - **Description**: excel 导入 导出 - **Primary Language**: C# - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-15 - **Last Updated**: 2025-09-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ExcelMapper Excel 操作封装 导入、导出 ## 安装 ``` dotnet add package Dust.ExcelMapper --version 1.0.0 ``` ## 例,如下 ``` using ExcelMapper; using ExcelMapper.Attributes; // 导出 var stream = await ExportConfig.GenDefaultConfig(new List { new { Name = "张三", Sex = 0, Birthday = DateTime.Now }, new { Name = "李四", Sex = 1, Birthday = DateTime.Now } }) .Add("名称", "Name", 30) .Add("性别", "Sex", 40) .Add("生日", "Birthday", 50) .Handler("性别", t => ((dynamic)t).Sex == 1 ? "女" : "男") .Handler("生日", t => ((dynamic)t).Birthday.ToString("yyyy-MM-dd HH:mm:ss")) .ExportAsync(); await using var sw = File.Create("D:\\monitor\\test.xlsx"); await stream.CopyToAsync(sw); // 导入 var result = await ReadConfig.ExcelToEntityAsync(stream); public class Demo { [Excel(ExcelField = "名称")] public string Name { get; set; } [Excel(ExcelField = "性别", ReadConverterExp = "0=男,1=女", Separator = ",")] public int Sex { get; set; } [Excel(ExcelField = "生日")] public DateTime? Birthday { get; set; } } ```