Using EPPlus-Core to Export Excel Documents in .NET Core (C#)
First, install Just install it via NuGet, super convenient. How to use There are many ways to export; this article only covers the most convenient one with the least code. First, define an entity class, for example: public class OutputData { public string Address { get; set; } public int Title { get; set; } public int Description { ge
目录3 个章节
First, install
Just install it via NuGet, super convenient.
How to use
There are many ways to export; this article only covers the most convenient one with the least code.
First, define an entity class, for example:
public class OutputData {
public string Address { get; set; }
public int Title { get; set; }
public int Description { get; set; }
public int Keywords { get; set; }
public int Content { get; set; }
public int Score { get; set; }
}
Then just pass a list of type OutputData and you can output an Excel file.
private static void ExportExcel(IEnumerable<OutputData> results) {
using var package = new ExcelPackage();
var worksheet = package.Workbook.Worksheets.Add("结果导出");
worksheet.Cells.LoadFromCollection(results, true);
package.SaveAs(new FileStream("output.xlsx", FileMode.Create));
}
Note: The second parameter of worksheet.Cells.LoadFromCollection() indicates outputting the header~
References
_EOF_
Using EPPlus-Core to Export Excel Documents in .NET Core (C#)
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
开发现代化的.NetCore控制台程序:(2)创建一个C#项目模板
又一个.NetCore模板?FluentConsole.Templates,一键生成骨架,包含DI、日志、配置。安装?dotnet new install,然后dotnet new flu-cli -n MyProject。太简单了吧,谁在乎?
2023-11-10 · C# · 约 1 分钟
使用C#和MemoryCache组件实现轮流调用APIKey以提高并发能力
本文介绍了如何利用C#语言中的MemoryCache组件,结合并发编程技巧,实现轮流调用多个API Key以提高系统的并发能力。通过示例代码和详细说明,读者将了解如何有效地管理API Key的调用次数限制,并优化系统性能。
2024-03-09 · C# · 约 1 分钟
纯 C#实现+AOT 打造的多功能图片处理工具 ImageGlider
纯C#+AOT打造的ImageGlider,图像处理功能堆得像山,还非得标榜零依赖?ImageSharp封装得倒是挺顺溜,就是不知道这模块化架构能走多远。Web API和CLI工具有点东西,但别指望我夸太离谱。
2025-08-05 · C# · 约 1 分钟
C#集成ViewFaceCore人脸检测识别库
人脸检测与识别现在已经很成熟了,C# 上有 ViewFaceCore 这个很方便的库,但这种涉及到 native 调用的库,一般会有一些坑,本文记录一下开发和部署的过程。
2023-09-20 · C# · 约 1 分钟
讨论
共 0 条加载评论中…