LiteExcel 2.4.77

dotnet add package LiteExcel --version 2.4.77
                    
NuGet\Install-Package LiteExcel -Version 2.4.77
                    
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="LiteExcel" Version="2.4.77" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LiteExcel" Version="2.4.77" />
                    
Directory.Packages.props
<PackageReference Include="LiteExcel" />
                    
Project file
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 LiteExcel --version 2.4.77
                    
#r "nuget: LiteExcel, 2.4.77"
                    
#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.
#:package LiteExcel@2.4.77
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LiteExcel&version=2.4.77
                    
Install as a Cake Addin
#tool nuget:?package=LiteExcel&version=2.4.77
                    
Install as a Cake Tool

LiteExcel

NuGet NuGet 下载量 CI .NET License

轻量级 .NET 库,无需安装 Excel 即可读写 xlsx / xlsm / xlsb / xls / csv 五种格式。零第三方依赖,net48 与 net8.0 双目标,AOT 友好。

English README

效果预览

以下均为 LiteExcel 写出的文件在 Excel 中打开的实际效果:

条件格式效果

超级表与筛选效果

图片与冻结窗格效果

<details> <summary>更多效果(样式与数字格式 · 批注与数据验证 · 合并与超链接)</summary>

样式与数字格式

批注与数据验证

合并与超链接

</details>

详细文档

特性

  • 零第三方依赖,仅用 .NET 基础类库,引用即用,部署包内没有额外原生组件。
  • net48 与 net8.0 双目标,公开 API 全部兼容 Native AOT 与裁剪,并以原生可执行文件实测。
  • 一套对象模型覆盖五种格式;同一段代码换个格式参数即可写出 xls 或 csv。
  • 覆盖常用办公需求:样式与数字格式、合并、筛选、行高列宽、批注、数据验证、超链接、冻结窗格、图片、条件格式、超级表、命名区域、公式、文件密码、大文件流式读写。
  • 打开再保存原样保留未改动的内容:xlsx / xlsm / xlsb 的宏、图表、透视表、数据模型、外部连接等高级部件不丢失。
  • 文件级安全:打开密码与修改密码、工作表与工作簿保护(可选密码)。
  • 大文件流式读写,内存占用平稳。
  • 写出 xls / xlsb / csv 时,目标格式不支持的能力逐项显式上报,绝不静默丢弃。

安装

dotnet add package LiteExcel

使用本地打包的 nupkg 时,指定包目录作为源:

dotnet add package LiteExcel --source .\packages

快速上手

对象模型读写:新建工作簿,按自然层级写入,再次打开读取。

using LiteExcel;

var wb = Excel.Create();
var ws = wb.Worksheets["Sheet1"];
ws.SetValue("A1", "姓名");
ws.SetValue("B1", "年龄");
ws.SetValue("A2", "张三");
ws.SetValue("B2", 25);
ws.Range("A1:B1").Style = new CellStyle { Bold = true };
wb.SaveAs("output.xlsx");

var opened = Excel.Open("output.xlsx");
var name = opened.Worksheets[0].Cell("A2").GetString();
var age = opened.Worksheets[0].Cells[2, 2].GetDouble();

List<T> 映射、DataTable、低层 SheetData 读写见使用手册第 2 章与附录 B。

能力矩阵

图例:☑️ 支持 · ❌ 不支持 · 单元格内文字表示部分支持

能力 xlsx xlsm xlsb xls csv
数据读写 ☑️ ☑️ ☑️ ☑️ 仅文本
样式与数字格式 ☑️ ☑️ 仅数字格式 仅数字格式 ❌
表格布局(合并 / 行高 / 列宽) ☑️ ☑️ ☑️ ☑️ ❌
自动筛选 ☑️ ☑️ 范围读写 ❌ ❌
批注 ☑️ ☑️ ☑️ ☑️ ❌
数据验证 ☑️ ☑️ ☑️ ❌ ❌
超级表 ☑️ ☑️ ☑️ ❌ ❌
命名区域 ☑️ ☑️ 仅读取 仅读取 ❌
超链接 ☑️ ☑️ ☑️ ☑️ ❌
冻结窗格 ☑️ ☑️ ☑️ ☑️ ❌
图片 ☑️ ☑️ 浮动写入 ❌ ❌
条件格式 ☑️ ☑️ 全类型写入 ❌ ❌
工作表可见性 / 标签颜色 ☑️ ☑️ 可见性支持 可见性支持 ❌
公式 ☑️ ☑️ 基础读写 基础读写 ❌
文件密码 ☑️ ☑️ ☑️ ❌ ❌
图表 / 透视表 原样保留 原样保留 原样保留 ❌ ❌
大文件流式读 ☑️ ☑️ ☑️ ☑️ ❌
大文件流式写 ☑️ ☑️ ❌ ❌ ❌

完整能力明细见使用手册 §20.1。

兼容性

  • 目标框架:net48、net8.0
  • AOT:公开 API 全部兼容 Native AOT 与裁剪;List<T> 反射映射已标注

已知边界

  1. 读取入口:Excel.Read<T> 只支持 xlsx / xlsm;xls / xlsb / csv 用 Excel.Open 按扩展名路由。
  2. CSV:单工作表、纯文本,无样式,数值以文本读回。
  3. 密码与宏:xls 不支持密码;含宏的工作簿只能存为 xlsm 或 xlsb。
  4. 图表与透视表:只保留不编辑;xlsx / xlsm / xlsb 打开再保存会原样保留,xls / csv 会丢弃。
  5. 流式与追加:只支持 xlsx / xlsm。

运行 Demo

仓库自带控制台示例(33 个 Demo,覆盖读写 / 样式 / 筛选 / 批注 / 密码 / 图片 / 条件格式 / 插删行列 / 公式写回等),在仓库根目录执行:

dotnet run --project demo/LiteExcel.Demo

输出写入程序目录下的 Output 文件夹,控制台会打印完整路径。

License

MIT LICENSE。

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • net8.0

    • No dependencies.

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.4.77 88 9/18/2026
2.4.76 89 9/15/2026
2.4.75 103 9/10/2026
2.4.74 99 9/9/2026
2.4.71 108 9/3/2026
2.4.7 108 8/27/2026
2.4.6 98 8/25/2026
2.4.5 105 8/24/2026
2.4.4 114 8/22/2026
2.4.3 93 8/22/2026
2.4.2 112 8/21/2026
2.4.1 108 8/19/2026
2.4.0 104 8/19/2026
2.3.0 123 8/18/2026
2.2.6 123 8/17/2026
2.2.5 113 8/15/2026
2.2.4 104 8/15/2026
2.2.3 109 8/15/2026
2.2.2 117 8/15/2026
2.2.1 109 8/15/2026
Loading failed