![]() |
VOOZH | about |
dotnet add package ZhileTime.IE.Word --version 1.1.0
NuGet\Install-Package ZhileTime.IE.Word -Version 1.1.0
<PackageReference Include="ZhileTime.IE.Word" Version="1.1.0" />
<PackageVersion Include="ZhileTime.IE.Word" Version="1.1.0" />Directory.Packages.props
<PackageReference Include="ZhileTime.IE.Word" />Project file
paket add ZhileTime.IE.Word --version 1.1.0
#r "nuget: ZhileTime.IE.Word, 1.1.0"
#:package ZhileTime.IE.Word@1.1.0
#addin nuget:?package=ZhileTime.IE.Word&version=1.1.0Install as a Cake Addin
#tool nuget:?package=ZhileTime.IE.Word&version=1.1.0Install as a Cake Tool
<img align="right" src="./res/logo.jpg" width="300"/>
👁 Member project of .NET Core Community
👁 nuget
👁 Build Status
👁 stats
👁 License
最近主要精力都在CodeSpirit,由于业余精力极其有限,ZhileTime.IE仅作间歇性维护。
地址(优先更新Gitee,路径沿用历史组织名):CodeSpirit(码灵)
说明:下文个别外部链接仍包含历史组织路径,仅为第三方平台沿用的地址命名,不代表当前项目名称。
简介:CodeSpirit(码灵)是一款革命性的全栈低代码智能体开发框架,通过智能代码生成引擎与AI深度协同,实现后端驱动式全栈开发范式。基于.NET 10技术栈构建,将具备企业级技术深度与云原生扩展能力,提供从界面生成、业务逻辑编排到系统运维的全生命周期支持。
让全栈开发回归工程本质
👁 Azure DevOps tests (master)
👁 Azure DevOps coverage (branch)
👁 Financial Contributors on Open Collective
导入导出通用库,支持Dto导入导出、模板导出、花式导出以及动态导出,支持Excel、Csv、Word、Pdf和Html。
具体见:https://dev.azure.com/xinlaiopencode/ZhileTime.IE/_build?definitionId=4&_a=summary
| 名称 | NuGet |
|---|---|
| ZhileTime.IE.Core | 👁 NuGet |
| ZhileTime.IE.Excel | 👁 NuGet |
| ZhileTime.IE.Excel.NPOI | 👁 NuGet |
| ZhileTime.IE.Excel.AspNetCore | 👁 NuGet |
| ZhileTime.IE.Pdf | 👁 NuGet |
| ZhileTime.IE.Word | 👁 NuGet |
| ZhileTime.IE.Html | 👁 NuGet |
| ZhileTime.IE.Csv | 👁 NuGet |
| ZhileTime.IE.AspNetCore | 👁 NuGet |
| ZhileTime.IE.EPPlus | 👁 NuGet |
其他教程见下文或单元测试
[Fact(DisplayName = "DTO导出支持动态类型")]
public async Task ExportAsBytesAsyncSupportDynamicType_Test()
{
IExcelExporter exporter = new ExcelExporter();
var filePath = GetTestFilePath($"{nameof(ExportAsBytesAsyncSupportDynamicType_Test)}.xlsx");
DeleteFile(filePath);
var source = GenFu.GenFu.ListOf<ExportTestDataWithAttrs>();
string fields = "text,number,name";
var shapedData = source.ShapeData(fields) as ICollection<ExpandoObject>;
var result = await exporter.ExportAsBytesAsync(shapedData);
result.ShouldNotBeNull();
result.Length.ShouldBeGreaterThan(0);
File.WriteAllBytes(filePath, result);
File.Exists(filePath).ShouldBeTrue();
}
/// <summary>
/// 性别
/// </summary>
[ImportHeader(Name = "性别")]
[Required(ErrorMessage = "性别不能为空")]
[ValueMapping(text: "男", 0)]
[ValueMapping(text: "女", 1)]
public Genders Gender { get; set; }
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class GenderLocalAttribute : ValueMappingsBaseAttribute
{
public override Dictionary<string, object> GetMappings(PropertyInfo propertyInfo)
{
var res= new Dictionary<string, object>();
res.Add("男",0);
res.Add("女",1);
return res;
}
}
/// <summary>
/// 性别
/// </summary>
[ImportHeader(Name = "性别")]
[Required(ErrorMessage = "性别不能为空")]
[GenderLocal]
public Genders Gender { get; set; }
支持枚举和Bool类型的导入数据验证项的生成,以及相关数据转换
枚举默认情况下会自动获取枚举的描述、显示名、名称和值生成数据项
/// <summary>
/// 学生状态 正常、流失、休学、勤工俭学、顶岗实习、毕业、参军
/// </summary>
public enum StudentStatus
{
/// <summary>
/// 正常
/// </summary>
[Display(Name = "正常")]
Normal = 0,
/// <summary>
/// 流失
/// </summary>
[Description("流水")]
PupilsAway = 1,
/// <summary>
/// 休学
/// </summary>
[Display(Name = "休学")]
Suspension = 2,
/// <summary>
/// 勤工俭学
/// </summary>
[Display(Name = "勤工俭学")]
WorkStudy = 3,
/// <summary>
/// 顶岗实习
/// </summary>
[Display(Name = "顶岗实习")]
PostPractice = 4,
/// <summary>
/// 毕业
/// </summary>
[Display(Name = "毕业")]
Graduation = 5,
/// <summary>
/// 参军
/// </summary>
[Display(Name = "参军")]
JoinTheArmy = 6,
}
bool类型默认会生成“是”和“否”的数据项
如果已设置自定义值映射,则不会生成默认选项
支持excel多Sheet导入;
支持Excel模板导出,JSON动态导出,并且支持图片渲染
渲染语法如下所示:
{{Company}} //单元格渲染
{{Table>>BookInfos|RowNo}} //表格渲染开始语法
{{Remark|>>Table}}//表格渲染结束语法
{{Image::ImageUrl?Width=50&Height=120&Alt=404}} //图片渲染
{{Image::ImageUrl?w=50&h=120&Alt=404}} //图片渲染
{{Image::ImageUrl?Alt=404}} //图片渲染
{{Formula::AVERAGE?params=G4:G6}} //公式渲染
{{Formula::SUM?params=G4:G6&G4}} //公式渲染
后续将支持自定义管道。
支持Excel导入模板生成标注
支持Excel图片导入导出
支持多个实体导出多个Sheet
支持使用System.ComponentModel.DataAnnotations命名空间下的部分特性来控制导入导出 #63
支持在ASP.NET Core Web API 中使用自定义格式化程序导出Excel、Pdf、Csv等内容,具体见教程 #64
支持分栏、分sheet、追加rows导出
await exporter.Append(list1).SeparateByColumn().Append(list2).ExportAppendDataFileAsync(filePath);
具体见上面教程《ZhileTime.IE之花式导出》
[ExportHeader(Width = 100)]
public DateTime Time3 { get; set; }
Excel导出支持HeaderRowIndex,在ExcelExporterAttribute导出特性类中添加HeaderRowIndex属性,方便导出时去指定从第一行开始导出。
Excel生成导入模板支持内置数据验证
对于内置数据验证的支持可通过IsInterValidation属性开启,并且需要注意的是仅支持MaxLengthAttribute、 MinLengthAttribute、 StringLengthAttribute、 RangeAttribute支持对内置数据验证的开启操作。 支持对输入提示的展示操作:
Excel导入支持合并行数据 #239
订阅号
关注“麦扣聊技术”订阅号可以获得最新文章、教程、文档,并且加入微信生态群:
<table> <tr> <td> <img align="left" src="./res/wechat.jpg" width="300"/> </td> <td> <img align="right" src="./res/IE_WeChat.png" width="300"/> </td> </tr> </table>
文档官网&官方博客
本项目感谢所有贡献者的支持。[]
<a href="https://github.com/dotnetcore/ZhileTime.IE/graphs/contributors"><img src="https://opencollective.com/magicodes/contributors.svg?width=890&button=false" /></a>
以下 OpenCollective 链接与徽章沿用历史组织路径,用于保留既有赞助与贡献记录。
成为财务贡献者,帮助我们维持社区发展。[贡献]
<a href="https://opencollective.com/magicodes"><img src="https://opencollective.com/magicodes/individuals.svg?width=890"></a>
用您的组织支持这个项目。您的徽标将显示在这里,并链接到您的网站。[贡献]
<a href="https://opencollective.com/magicodes/organization/0/website"><img src="https://opencollective.com/magicodes/organization/0/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/1/website"><img src="https://opencollective.com/magicodes/organization/1/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/2/website"><img src="https://opencollective.com/magicodes/organization/2/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/3/website"><img src="https://opencollective.com/magicodes/organization/3/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/4/website"><img src="https://opencollective.com/magicodes/organization/4/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/5/website"><img src="https://opencollective.com/magicodes/organization/5/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/6/website"><img src="https://opencollective.com/magicodes/organization/6/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/7/website"><img src="https://opencollective.com/magicodes/organization/7/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/8/website"><img src="https://opencollective.com/magicodes/organization/8/avatar.svg"></a> <a href="https://opencollective.com/magicodes/organization/9/website"><img src="https://opencollective.com/magicodes/organization/9/avatar.svg"></a>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on ZhileTime.IE.Word:
| Package | Downloads |
|---|---|
|
ZhileTime.IE.AspNetCore
ZhileTime.IE 导入导出组件库,支持 Excel、Csv、Word、Pdf 与 Html 等多种格式。 |
|
|
ZhileTime.Hope.Downloader.IE
Package Description |
This package is not used by any popular GitHub repositories.
变更记录请参考仓库根目录 CHANGELOG.md。