ExcelUtility 1.1.4
dotnet add package ExcelUtility --version 1.1.4
NuGet\Install-Package ExcelUtility -Version 1.1.4
<PackageReference Include="ExcelUtility" Version="1.1.4" />
<PackageVersion Include="ExcelUtility" Version="1.1.4" />
<PackageReference Include="ExcelUtility" />
paket add ExcelUtility --version 1.1.4
#r "nuget: ExcelUtility, 1.1.4"
#addin nuget:?package=ExcelUtility&version=1.1.4
#tool nuget:?package=ExcelUtility&version=1.1.4
EPPlusHelper
https://www.cnblogs.com/ives/p/ExcelUtility.html
安装:
Install-Package ExcelUtility -Version 1.0.0
需要为对象添加特性,
[Column]
//试用Column指定需要保存到excel中的字段
[Description(description:"ATest")]
//使用Description添加表头显示的名称
public class Table
{
[Column]
[Description(description:"ATest")]
public string A { get; set; }
[Column]
[Description(description: "BTest")]
public string B { get; set; }
}
需要注意单元格定位从0开始
//首先构造需要保存的对象
var testData = new List<Entity.Table>() {
new Entity.Table { A = "11111f", B = "1111111111111fff" },
new Entity.Table { A = "1111f", B = "111111fff" }
};
//在构造函数中传入表名,如果存在此文件则会删除旧文件
using (var tools = new ExcelHelper(new System.IO.FileInfo("test.xls")))
{
//1:自动化的将list中的数据写入表格
//写入默认的sheet1中
tools.SetData<Entity.Table>(testData);
//可以指定写入的表名
//tools.SetData<Entity.Table>(testData, "testSheet");
tools.Save();
}
using (var tools = new ExcelHelper(new System.IO.FileInfo("test.xls")))
{
//2:提供自定义的方式向任何表写入数据
//首先获取指定的sheet页
//提供默认参数为sheet1,即默认的sheet页
//var workSheet = tools.GetWorkSheet();
//也可以指定sheet页名称
var workSheet = tools.GetWorkSheet("newSheetName");
//向指定的单元格写入数据
workSheet.WriteCell(0, 0, "value");
tools.Save();
}
将excel中的数据映射到指定的数据类型
要求同上,需要
[Column]
//试用Column指定需要保存到excel中的字段
[Description(description:"ATest")]
//使用Description添加表头显示的名称
使用方式如下
//选择需要转换的表格并指定欲转换类型
var t = new Excel2Data<Table>(new System.IO.FileInfo("test.xls"));
//指定待转换的sheet页,默认值为sheet1
//var data = t.GetData();
var data=t.GetData("newSheetName");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
.NET Core | netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
-
.NETCoreApp 3.0
- EPPlus (>= 4.5.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.
添加对单元格中的数据为空时,将属性值赋值为定义类型的默认值的支持