网站建设品牌,湖北城乡建设厅网站,龙岩网站设计 信任推商吧做词,网站开发公司哪个好在2.3这一版本的更新中#xff0c;我们迎来了众多的使用者、贡献者#xff0c;在这个里程碑中我们也添加并修复了一些功能。对于新特点的功能我将在下面进行详细的描述#xff0c;当然也欢迎更多的人可以加入进来#xff0c;再或者也很期待大家来提issues或者PR#xff0c… 在2.3这一版本的更新中我们迎来了众多的使用者、贡献者在这个里程碑中我们也添加并修复了一些功能。对于新特点的功能我将在下面进行详细的描述当然也欢迎更多的人可以加入进来再或者也很期待大家来提issues或者PR您的一个issue或者PR将是我们前进的动力。公式导出 #88https://github.com/dotnetcore/Magicodes.IE/issues/88公式导出目前已经在Excel模板导出中支持我们可以通过如上代码片段的格式进行将公式应用到我们的Excel导出模板中.{{Formula::AVERAGE?paramsG4:G6}}
{{Formula::SUM?paramsG4:G6G4}}
增加分栏、分sheet、追加rows导出 #74https://github.com/dotnetcore/Magicodes.IE/issues/74在该版本中我们支持使用链式编程导出我们的Excel从而起到追加分栏等作用。在多个DTO导出中我们可以通过如下代码片段将我们的Excel分栏导出exporter.Append(list1).SeparateByColumn().Append(list2).ExportAppendData(filePath);
导出形式如下所示header 1header 2header1row 1 col 1row 1 col 2row1row 2 col 1row 2 col 2row2我们还可以通过多个DTO进行多Sheet的导出如下代码片段所示exporter.Append(list1).SeparateBySheet().Append(list2).ExportAppendData(filePath);
当然不仅仅是这样我们还可以对行进行追加导出同时我们可以选择导出额外的Header信息或者不导出exporter.Append(list1).SeparateByRow().Append(list2).ExportAppendData(filePath);
header 1header 2header1row 1 col 1row 1 col 2row1row 2 col 1row 2 col 2row2row 2 col 1row 2 col 2row2或者我们可以这样加入Header信息exporter.Append(list1).SeparateByRow().AppendHeaders().Append(list2).ExportAppendData(filePath);
header 1header 2header1row 1 col 1row 1 col 2row1row 2 col 1row 2 col 2row2header 1header 2header1row 2 col 1row 2 col 2row2添加对ExpandoObject类型的支持#135(https://github.com/dotnetcore/Magicodes.IE/issues/135特别感谢 sgalcheung(https://github.com/sgalcheung)添加该特性的导出具体使用方式如下所示class Program{static async Task Main(string[] args){IExporter exporter new ExcelExporter();// 生成测试数据var personList GenFu.GenFu.ListOfPerson();// 导出一个只包含FirstName, LastName列的excelstring fields FirstName,LastName; // 可自定义导出想要的字段var expandoObjectList new ListExpandoObject(personList.Count);var propertyInfoList new ListPropertyInfo();var fieldsAfterSplit fields.Split(,);foreach (var field in fieldsAfterSplit){var propertyName field.Trim();var propertyInfo typeof(Person).GetProperty(propertyName);if (propertyInfo null){throw new Exception($Property: {propertyName} 没有找到{typeof(Person)});}propertyInfoList.Add(propertyInfo);}foreach (var person in personList){var shapedObj new ExpandoObject();foreach (var propertyInfo in propertyInfoList){var propertyValue propertyInfo.GetValue(person);((IDictionarystring, object)shapedObj).Add(propertyInfo.Name, propertyValue);}expandoObjectList.Add(shapedObj);}string filePath Path.Combine(Directory.GetCurrentDirectory(), dynamicExportExcel.xlsx);var result await exporter.ExportAsByteArrayExpandoObject(expandoObjectList);File.WriteAllBytes(filePath, result);}}class Person{public string FirstName { get; set; }public string LastName { get; set; }public string Title { get; set; }public int Age { get; set; }public int NumberOfKids { get; set; }}
感谢大家对Magicodes.IE的支持。关于更多发布信息大家可以参阅https://github.com/dotnetcore/Magicodes.IE/blob/master/RELEASE.mdhttps://github.com/dotnetcore/Magicodes.IE转载是一种动力 分享是一种美德如果喜欢作者的文章请关注【麦扣聊技术】订阅号以便第一时间获得最新内容。本文版权归作者和湖南心莱信息科技有限公司共有欢迎转载但未经作者同意必须保留此段声明且在文章页面明显位置给出原文连接否则保留追究法律责任的权利。原文作者HueiFeng文档官网docs.xin-lai.comQQ群编程交流群85318032 产品交流群897857351