YF.CSharp.Tools
1.1.0
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package YF.CSharp.Tools --version 1.1.0
NuGet\Install-Package YF.CSharp.Tools -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YF.CSharp.Tools" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YF.CSharp.Tools" Version="1.1.0" />
<PackageReference Include="YF.CSharp.Tools" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YF.CSharp.Tools --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: YF.CSharp.Tools, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=YF.CSharp.Tools&version=1.1.0
#tool nuget:?package=YF.CSharp.Tools&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Word模板处理
- 处理模板文件
- 提前处理好模板文件所有的样式,包括且不限于文本格式、段落格式、页眉页脚、水印等。模板文件限定 docx 格式。
- 需要进行文本赋值的,将文本替换为 $FieldName$ 。
- 需要进行表格赋值的,将表格内容行数调整为一行,并将每个单元格的文本设置为 #TableName#ColumnName# 。
- 处理数据Model
- 文本赋值字段名称,与模板中 FieldName 相对应,限定 String 类型。
- 表格赋值字段名称,与模板中 TableName 相对应,限定 List<T> 类型。T 成员字段名称,与模板中 ColumnName 相对应,限定 String 类型。
- 示例
var model = InitModel(); // 获取数据Model
var officeWord = new EasyOfficeWord(templateFilePath).SetData(model); //生成文件
officeWord.SaveToFile(savePath); // 保存文件至指定路径
officeWord.SaveToByteArray(); // 获取文件字节数组
Excel财务公式计算
double fv = OfficeExcelFunction.FV(rate, nper, pmt, pv, type);
double impt = OfficeExcelFunction.IPMT(rate, per, nper, pv, fv, type);
double pmt = OfficeExcelFunction.PMT(rate, nper, pv, fv, type);
double ppmt = OfficeExcelFunction.PPMT(rate, per, nper, pv, fv, type);
数据校验
- 支持如下校验特性
[CaseField] // 该字段将被用作Case条件,此特性必须在Case条件前声明
pubile int Field1 { get; set; }
[RequiredField] // 该字段必填
pubile String Field2 { get; set; }
[RequiredField(Case = "Field1 = 3")] // 该字段在Field1 = 3时必填
pubile String Field3 { get; set; }
[ValidField(1, 3, 5)] // 该字段只能取1,3,5
pubile int Field4 { get; set; }
[FieldRange(1.5, 3.5)] // 数值必须>=1.5且<=3.5
pubile double Field5 { get; set; }
[FieldContains(Min = 1, Max = 9)] // 该字段至少需要包含1个元素,最多包含9个元素
pubile List<object> Field6 { get; set; }
[FieldLength(Min = 50, Max = 100)] // 字符串长度不能少于50,不能多于100
pubile String Field7 { get; set; }
[DatetimeField] // 字符串是合法的时间格式
pubile String Field8 { get; set; }
[EmailField] // 字符串是合法的Email格式
pubile String Field9 { get; set; }
[MobileField] // 字符串是合法的手机号码
pubile String Field10 { get; set; }
[UrlField] // 字符串是合法的网址(http://或https://开头,忽略大小写)
pubile String Field11 { get; set; }
[IdCardField] // 字符串是有效的15位或18位身份证号码(不会进行真实性校验)
pubile String Field12 { get; set; }
- Case条件定义
- 定义字符串为 左值+英文单空格+操作符+英文单空格+右值,如 Case = "Field1 = 3"
- 左值为 CaseField字段名,需 提前声明 。
- 右值为和 CaseFiled字段类型 相对应的判断值。
- 操作符有
- = 或 ==:判断左右值相等。支持字符串、日期、数值。当类型为数值时,3与3.0将被认为相等。
- !=:判断左右值不相等。支持字符串、日期、数值。当类型为数值时,3与3.0将被认为相等。
- >:判断左值大于右值。支持日期、数值。
- >=:判断左值大于等于右值。支持日期、数值。
- <:判断左值小于右值。支持日期、数值。
- <=:判断左值小于等于右值。支持日期、数值。
- in:判断左值包含在右值中。支持字符串、数值。右值多个数据用 英文逗号 分隔,如 Case = "Field1 IN 1,3,5"
- notin:判断左值不包含在右值中。支持字符串、数值。右值多个数据用 英文逗号 分隔,如 Case = "Field1 NOTIN 1,3,5"
- is: 共计4种,分别为is true, is false, is null, is not null。当判断true或false时,左值必须可以转换为bool。
- 数据检验接口
public class Model : IDataValidator {
// 类成员
public void Verify() {
// 校验方法,请抛出 DataValidationException 异常
}
}
- 字段名称定义及报错信息定义
- 若该字段有 DescriptionAttribute 特性,则取该特性作为名称。否则取该字段 PropertyInfo.Name 为名称。
- 若校验特性中单独定义了 Message 属性,则取该属性作为报错信息。否则取默认报错信息。
- 校验失败 校验失败会抛出 DataValidationException 异常,需自行捕获处理。
- 示例
var model = InitModel(); // 获取数据Model。成员校验特性配置见上。
DataValidator.Verify(model);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
- NPOI (>= 2.5.5)
- Portable.BouncyCastle (>= 1.8.9)
- SharpZipLib (>= 1.3.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|
First release.