2024.01.03
2023.04.22
2023.03.16
2023.01.04
2023.01.02
2022.12.30
2022.12.27
2022.12.04
2022.12.01
2022.11.07
2022.10.27
2022.10.26
2022.10.18
2022.10.12
2022.07.17
2022.04.17
优化了ColumnIndex在生成模板时的实现,增加了ColumnIndex的单测(见PR#385)。
添加了NPOI的独立扩展包——Magicodes.IE.Excel.NPOI,以便于后续给用户提供更多的支持。目前仅提供了 SaveToExcelWithXSSFWorkbook 扩展方法。
修复RequiredIfAttribute的Bug。
修复导出JPG图片在Linux环境下可能引起的无限循环的问题(见PR#396)。
Excel图片导入时,图片列支持为空。
更新CsvHelper到最新版本,并修改相关代码。
2022.03.06
builder.Services.AddTransient<IImportHeaderFilter, ImportHeaderFilterA>();
builder.Services.AddTransient<IImportHeaderFilter, ImportHeaderFilterB>();
builder.Services.AddTransient<IImportHeaderFilter, ImportHeaderFilterC>();
[ExcelImporter(ImportHeaderFilter = typeof(ImportHeaderFilterB))]
public class ImportExcelTemplateDto
{
[ImporterHeader(Name = "TypeName")]
public string? Name { get; set; }
}
2022.03.02
[Fact(DisplayName = "导入结果回调函数测试")]
public async Task ImportResultCallBack_Test()
{
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "TestFiles", "Import", "缴费流水导入模板.xlsx");
var import = await Importer.Import<ImportPaymentLogDto>(filePath, (importResult) =>
{
int rowNum = 2;//首行数据对应Excel中的行号
foreach (var importPaymentLogDto in importResult.Data)
{
if (importPaymentLogDto.Amount > 5000)
{
var dataRowError = new DataRowErrorInfo();
dataRowError.RowIndex = rowNum;
dataRowError.FieldErrors.Add("Amount", "金额不能大于5000");
importResult.RowErrors.Add(dataRowError);
}
rowNum++;
}
return importResult;
});
import.ShouldNotBeNull();
import.HasError.ShouldBeTrue();
import.RowErrors.ShouldContain(p => p.RowIndex == 3 && p.FieldErrors.ContainsKey("金额不能大于5000"));
import.Exception.ShouldBeNull();
import.Data.Count.ShouldBe(20);
}
2021.11.28
添加两个动态验证特性(见PR#319 by Afonsof91):
DynamicStringLengthAttribute
,以便支持动态配置字符串长度验证。使用参考:public class DynamicStringLengthImportDto
{
[ImporterHeader(Name = "名称")]
[Required(ErrorMessage = "名称不能为空")]
[DynamicStringLength(typeof(DynamicStringLengthImportDtoConsts), nameof(DynamicStringLengthImportDtoConsts.MaxNameLength), ErrorMessage = "名称字数不能超过{1}")]
public string Name { get; set; }
}
public static class DynamicStringLengthImportDtoConsts
{
public static int MaxNameLength { get; set; } = 3;
}
RequiredIfAttribute
,以支持动态开启必填验证。使用参考:public class RequiredIfAttributeImportDto
{
[ImporterHeader(Name = "名称是否必填")]
[Required(ErrorMessage = "名称是否必填不能为空")]
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool IsNameRequired { get; set; }
[ImporterHeader(Name = "名称")]
[RequiredIf("IsNameRequired", "True", ErrorMessage = "名称不能为空")]
[MaxLength(10, ErrorMessage = "名称字数超出最大值:10")]
public string Name { get; set; }
}
CSV添加对分隔符的配置,具体见PR#319 by Afonsof91
Excel导入添加对TimeSpan
类型的支持,使用参考TimeSpan_Test
初步添加对.NET6的适配
2021.10.23
2021.10.13
2021.10.06
2021.10.05
2021.09.02
2021.08.27
2021.08.24
2021.08.07
Magicodes.IE.Excel.AspNetCore
工程,添加XlsxFileResult
的Action Result,支持泛型集合、Bytes数组、Steam直接导出2021.07.23
2021.07.15
2021.07.04
2021.06.29
2021.06.25
2021.06.18
2021.06.05
2021.06.05
2021.06.01
2021.05.26
2021.05.10
2021.04.23
2021.04.18
[ImporterHeader(Name = "序号", Format ="@")]
**YOffset**:垂直偏移(可进行移动图片)
**XOffset**:水平偏移(可进行移动图片)
[ExcelImporter(SheetIndex = 2)]
2021.04.13
2021.04.06
2021.04.03
2021.03.30
2021.03.12
2021.03.08
2021.03.05
2021.02.23
2021.02.20
2021.01.31
2021.01.29
2021.01.09
2021.01.02
2020.12.21
2020.12.03
2020.11.26
2020.11.25
2020.11.20 To fix The Mapping Values of The total length of a Data Validation list always exceed 255 characters (# 196) (https://github.com/dotnetcore/Magicodes.IE/issues/196)
2020.10.29
2020.10.20
2020.10.01
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
AppDependencyResolver.Init(app.ApplicationServices);
//all other code
}
2020.09.26
2020.09.24
2020.09.16
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
AppDependencyResolver.Init(app.ApplicationServices);
//all other code
}
2020.09.14
2020.08.30
2020.08.22
2020.08.16
2020.08.10
2020.08.04
COM Interop is not supported on this platform.
修复 #130
2020.07.14
2020.07.13
2020.07.06
【Nuget】版本更新到2.3.0-beta2
【Excel导出】导出业务错误数据支持直接返回错误数据的文件流字节
【Excel导出】对追加sheet实现同一个Model可自定义传入不同sheet名称
【Nuget】针对于一些客户端不支持SemVer 2.0.0 进行采取兼容机制
2020.06.22
【Nuget】版本更新到2.3.0-beta1
【Excel导出】添加对Excel模板导出函数的支持
- {{Formula::AVERAGE?params=G4:G6}}
- {{Formula::SUM?params=G4:G6&G4}}
2020.06.16
2020.06.14
【Nuget】版本更新到2.2.5
【Excel导出】增加分栏、分sheet、追加rows导出 #74
- exporter.Append(list1).SeparateByColumn().Append(list2).ExportAppendData(filePath);
- exporter.Append(list1).SeparateBySheet().Append(list2).ExportAppendData(filePath);
- exporter.Append(list1).SeparateByRow().AppendHeaders().Append(list2).ExportAppendData(filePath);
[Excel导出】修复‘IsAllowRepeat=true’ #107
[Pdf导出】增加PDF扩展方法,支持通过以参数形式传递特性参数 #104
- Task<byte[]> ExportListBytesByTemplate<T>(ICollection<T> data, PdfExporterAttribute pdfExporterAttribute,string temple);
- Task<byte[]> ExportBytesByTemplate<T>(T data, PdfExporterAttribute pdfExporterAttribute,string template);
2020.06.07
导入失败
仅返回错误行功能SeparateByColumn
进行分割追加列【Nuget】版本更新到2.2.0-beta8
【Excel模板导出】支持图片 #62,渲染语法如下所示:
{{Image::ImageUrl?Width=50&Height=120&Alt=404}}
{{Image::ImageUrl?w=50&h=120&Alt=404}}
{{Image::ImageUrl?Alt=404}}
/// <summary>
/// 追加集合到当前导出程序
/// append the collection to context
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="dataItems"></param>
/// <returns></returns>
ExcelExporter Append<T>(ICollection<T> dataItems) where T : class;
/// <summary>
/// 导出所有的追加数据
/// export excel after append all collectioins
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
Task<ExportFileInfo> ExportAppendData(string fileName);
/// <summary>
/// 导出所有的追加数据
/// export excel after append all collectioins
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
Task<byte[]> ExportAppendDataAsByteArray();
var exporter = new ExcelExporter();
var list1 = GenFu.GenFu.ListOf<ExportTestDataWithAttrs>();
var list2 = GenFu.GenFu.ListOf<ExportTestDataWithSplitSheet>(30);
var result = exporter.Append(list1).Append(list2).ExportAppendData(filePath);
/// <summary>
/// 导出Excel
/// </summary>
/// <param name="fileName">文件名称</param>
/// <param name="dataItems">数据</param>
/// <param name="exporterHeaderFilter">表头筛选器</param>
/// <param name="maxRowNumberOnASheet">一个Sheet最大允许的行数,设置了之后将输出多个Sheet</param>
/// <returns>文件</returns>
Task<ExportFileInfo> Export(string fileName, DataTable dataItems, IExporterHeaderFilter exporterHeaderFilter = null, int maxRowNumberOnASheet = 1000000);
/// <summary>
/// 导出Excel
/// </summary>
/// <param name="dataItems">数据</param>
/// <param name="exporterHeaderFilter">表头筛选器</param>
/// <param name="maxRowNumberOnASheet">一个Sheet最大允许的行数,设置了之后将输出多个Sheet</param>
/// <returns>文件二进制数组</returns>
Task<byte[]> ExportAsByteArray(DataTable dataItems, IExporterHeaderFilter exporterHeaderFilter = null, int maxRowNumberOnASheet = 1000000);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。