Yyt.Abp.Excel
1.0.2
dotnet add package Yyt.Abp.Excel --version 1.0.2
NuGet\Install-Package Yyt.Abp.Excel -Version 1.0.2
<PackageReference Include="Yyt.Abp.Excel" Version="1.0.2" />
<PackageVersion Include="Yyt.Abp.Excel" Version="1.0.2" />
<PackageReference Include="Yyt.Abp.Excel" />
paket add Yyt.Abp.Excel --version 1.0.2
#r "nuget: Yyt.Abp.Excel, 1.0.2"
#:package Yyt.Abp.Excel@1.0.2
#addin nuget:?package=Yyt.Abp.Excel&version=1.0.2
#tool nuget:?package=Yyt.Abp.Excel&version=1.0.2
Yyt.Abp.Excel
English Version
Overview
Yyt.Abp.Excel is a library that simplifies the implementation of Excel import and export functionality for .NET applications, Version 1.0.2 added support for net8. Built with a modular architecture, it can be seamlessly integrated into your existing projects. Supported by Patrick.Z, this library streamlines repetitive daily development configurations in .NET applications and takes the heavy lifting off your shoulders.
Why Choose Yyt.Abp.Excel?
- Minimal Dependencies: Lightweight design with few external dependencies, keeps your project lean and efficient.
- Secure by Design: Security is prioritized from the design phase to reduce potential vulnerabilities.
- Highly Extensible: Easy to extend and customize to meet your specific business requirements.
- Battle-Tested: Proven stable and reliable through validation in multiple production projects.
Code Invocation Example
Export Example
public class EntityModelFileExporter : FileExporterBase
{
public FileDto ExportDataToFile(List<EntityFieldListDto> entityFieldListDto, string tempFileDownloadFolder)
{
var FileName = "EntityFields";
var SheetName = "EntityFields";
List<string> headerList = new List<string>();
List<Func<EntityFieldListDto, object>> propertySelectorList = new List<Func<EntityFieldListDto, object>>();
headerList.Add("Name");
headerList.Add("ColumnName");
propertySelectorList.Add(d => d.Name);
propertySelectorList.Add(d => d.ColumnName);
string[] header = headerList.ToArray();
Func<EntityFieldListDto, object>[] propertySelectors = propertySelectorList.ToArray();
var exportFileDto = CreateExcelPackage(
FileName,
excelPackage =>
{
var sheet = excelPackage.Workbook.Worksheets.Add(SheetName);
sheet.OutLineApplyStyle = true;
AddHeader(
sheet,
header
);
;
AddObjects(
sheet, 2, entityFieldListDto, propertySelectors
);
var timeColumn = sheet.Column(1);
timeColumn.Style.Numberformat.Format = "yyyy-mm-dd hh:mm:ss";
for (var i = 1; i <= 10; i++)
{
if (i.IsIn(5, 10))
{
continue;
}
sheet.Column(i).AutoFit();
}
}, tempFileDownloadFolder);
var fileDto = new FileDto();
fileDto.FileName = exportFileDto.FileName;
fileDto.FileToken = exportFileDto.FileToken;
fileDto.MimeType = exportFileDto.MimeType;
return fileDto;
}
}
Import Example
public class EntityModelsFileImporter : FileImporterBase
{
public async Task<ServiceResult<List<EntityFieldImportFailDto>>> ImportFileToData(ImportEntityFieldsToDataInput input)
{
var result = new ServiceResult<List<EntityFieldImportFailDto>>();
var formFile = input.File as IFormFile;
DataTable importDt = new DataTable();
Stream importFileStream = null;
try
{
importFileStream = formFile.OpenReadStream();
importDt = ImportExcel(importFileStream, "sheet1");
}
catch
{
}
finally
{
if (importFileStream != null)
{
importFileStream.Close();
importFileStream.Dispose();
}
}
if (importDt.Rows.Count > 0)
{
DataView importDv = new DataView(importDt);
string[] importClomns = { "name", "tablename", };
try
{
importDt = importDv.ToTable(true, importClomns);
}
catch
{
}
//save to db
//...
result.IsSuccess($"import success!");
result.Data = fieldImportFailDtoList;
return await Task.FromResult(result);
}
else
{
result.IsFailed("import fail!");
return await Task.FromResult(result);
}
}
}
Chinese Version
概述
Yyt.Abp.Excel 提供了简化 .Net 程序实现 Excel 导入导出功能,Version 1.0.2 增加了对net8的支持。。代码采用了 Module 模块化设计,能无缝集成到项目中。该库由 Patrick.Z 提供支持,简化了 .Net 应用程序中的日常开发配置工作,为您分担繁重的工作。
为什么选择 Yyt.Abp.Excel?
- 极少依赖:轻量级设计,外部依赖少,保持项目精简高效
- 设计安全:从设计阶段就优先考虑安全性,减少潜在漏洞
- 可扩展定制:易于扩展和定制,满足特定业务需求
- 久经沙场:经过多个生产项目验证,稳定可靠
代码调用示例
导出示例
public class EntityModelFileExporter : FileExporterBase
{
public FileDto ExportDataToFile(List<EntityFieldListDto> entityFieldListDto, string tempFileDownloadFolder)
{
var FileName = "EntityFields";
var SheetName = "EntityFields";
List<string> headerList = new List<string>();
List<Func<EntityFieldListDto, object>> propertySelectorList = new List<Func<EntityFieldListDto, object>>();
headerList.Add("Name");
headerList.Add("ColumnName");
propertySelectorList.Add(d => d.Name);
propertySelectorList.Add(d => d.ColumnName);
string[] header = headerList.ToArray();
Func<EntityFieldListDto, object>[] propertySelectors = propertySelectorList.ToArray();
var exportFileDto = CreateExcelPackage(
FileName,
excelPackage =>
{
var sheet = excelPackage.Workbook.Worksheets.Add(SheetName);
sheet.OutLineApplyStyle = true;
AddHeader(
sheet,
header
);
;
AddObjects(
sheet, 2, entityFieldListDto, propertySelectors
);
var timeColumn = sheet.Column(1);
timeColumn.Style.Numberformat.Format = "yyyy-mm-dd hh:mm:ss";
for (var i = 1; i <= 10; i++)
{
if (i.IsIn(5, 10))
{
continue;
}
sheet.Column(i).AutoFit();
}
}, tempFileDownloadFolder);
var fileDto = new FileDto();
fileDto.FileName = exportFileDto.FileName;
fileDto.FileToken = exportFileDto.FileToken;
fileDto.MimeType = exportFileDto.MimeType;
return fileDto;
}
}
导入示例
public class EntityModelsFileImporter : FileImporterBase
{
public async Task<ServiceResult<List<EntityFieldImportFailDto>>> ImportFileToData(ImportEntityFieldsToDataInput input)
{
var result = new ServiceResult<List<EntityFieldImportFailDto>>();
var formFile = input.File as IFormFile;
DataTable importDt = new DataTable();
Stream importFileStream = null;
try
{
importFileStream = formFile.OpenReadStream();
importDt = ImportExcel(importFileStream, "sheet1");
}
catch
{
}
finally
{
if (importFileStream != null)
{
importFileStream.Close();
importFileStream.Dispose();
}
}
if (importDt.Rows.Count > 0)
{
DataView importDv = new DataView(importDt);
string[] importClomns = { "name", "tablename", };
try
{
importDt = importDv.ToTable(true, importClomns);
}
catch
{
}
//save to db
//...
result.IsSuccess($"import success!");
result.Data = fieldImportFailDtoList;
return await Task.FromResult(result);
}
else
{
result.IsFailed("import fail!");
return await Task.FromResult(result);
}
}
}
Document Version: v1.0
Created Date: June 2026
Author: Patrick.Z
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net6.0
- DocumentFormat.OpenXml (>= 2.20.0)
- EPPlus (>= 4.5.3.3)
- Volo.Abp.AspNetCore (>= 6.0.2)
- Volo.Abp.Ddd.Application (>= 6.0.2)
-
net8.0
- DocumentFormat.OpenXml (>= 2.20.0)
- EPPlus (>= 4.5.3.3)
- Volo.Abp.AspNetCore (>= 8.0.0)
- Volo.Abp.Ddd.Application (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.