Newcats.Office 2.0.0

dotnet add package Newcats.Office --version 2.0.0
NuGet\Install-Package Newcats.Office -Version 2.0.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="Newcats.Office" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Newcats.Office --version 2.0.0
#r "nuget: Newcats.Office, 2.0.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.
// Install Newcats.Office as a Cake Addin
#addin nuget:?package=Newcats.Office&version=2.0.0

// Install Newcats.Office as a Cake Tool
#tool nuget:?package=Newcats.Office&version=2.0.0

Newcats.Office 使用说明

Net Core Nuget Newcats.Office GitHub License

示例代码:

Newcats.Office.Excel

//1.读取Excel到DataTable(默认获取第一个Sheet)(第一行为表头,不记录数据)
const string fullFileName = @"C:\Users\Newcats\Desktop\Result_108.xlsx";
DataTable r1 = Newcats.Office.Excel.ReadExcelToTable(fullFileName);

//2.从流读取Excel到DataTable(默认获取第一个Sheet)(第一行为表头,不记录数据)
using (FileStream fs = new(fullFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
    DataTable r2 = Newcats.Office.Excel.ReadExcelToTable(fs, Newcats.Office.Excel.ExcelFormatEnum.xlsx);
}

//3.从Http读取Excel到DataTable(默认获取第一个Sheet)(第一行为表头,不记录数据)
[HttpPost]
public async Task<IActionResult> UploadFile(IFormFile file)
{
    DataTable r3 = Newcats.Office.Excel.ReadExcelToTable(file);
    return Ok(r3);
}

//4.读取DataTable数据源到Excel内存流
using (MemoryStream r4 = Newcats.Office.Excel.ReadDataTableToExcel(r1))
{

}

//5.读取Excel到List
List<DepartmentInfo> r5 = Newcats.Office.Excel.ReadExcelToList<DepartmentInfo>(fullFileName);

//6.读取Excel到List
using (FileStream fs = new(fullFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
    List<DepartmentInfo> r6 = Newcats.Office.Excel.ReadExcelToList<DepartmentInfo>(fs, Newcats.Office.Excel.ExcelFormatEnum.xlsx);
}

//7.读取Excel到List
[HttpPost]
public async Task<IActionResult> UploadFile(IFormFile file)
{
    List<DepartmentInfo> r7 = Newcats.Office.Excel.ReadExcelToTable<DepartmentInfo>(file);
    return Ok(r7);
}

//8.读取List数据源到Excel内存流
using (MemoryStream r8 = Newcats.Office.Excel.ReadListToExcel<DepartmentInfo>(r5, Newcats.Office.Excel.ExcelFormatEnum.xlsx))
{

}

贡献与反馈

如果你在阅读或使用任意一个代码片断时发现Bug,或有更佳实现方式,欢迎提Issue。

对于你提交的代码,如果我们决定采纳,可能会进行相应重构,以统一代码风格。

对于热心的同学,将会把你的名字放到贡献者名单中。


免责声明

  • 虽然代码已经进行了高度审查,并用于自己的项目中,但依然可能存在某些未知的BUG,如果你的生产系统蒙受损失,本人不会对此负责。
  • 出于成本的考虑,将不会对已发布的API保持兼容,每当更新代码时,请注意该问题。

协议

MIT © Newcats


作者: newcats-2020/05/04

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 136 9/1/2023
1.0.9 278 1/8/2022
1.0.8 241 12/30/2021
1.0.7 250 12/28/2021
1.0.6 284 12/19/2021
1.0.5 273 12/14/2021
1.0.3 271 12/9/2021
1.0.2 260 11/18/2021
1.0.1 323 10/20/2021
1.0.0 276 9/2/2021

2023-9-1
1.底层改为使用MiniExcel包

2022-1-8
1.取消对Newcats.Utils包的依赖

2021-12-28
1.增加详细的使用说明文档,详见github