MiniExcel 2.0.0-preview.3

Prefix Reserved
This is a prerelease version of MiniExcel.
dotnet add package MiniExcel --version 2.0.0-preview.3
                    
NuGet\Install-Package MiniExcel -Version 2.0.0-preview.3
                    
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="MiniExcel" Version="2.0.0-preview.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiniExcel" Version="2.0.0-preview.3" />
                    
Directory.Packages.props
<PackageReference Include="MiniExcel" />
                    
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 MiniExcel --version 2.0.0-preview.3
                    
#r "nuget: MiniExcel, 2.0.0-preview.3"
                    
#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 MiniExcel@2.0.0-preview.3
                    
#: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=MiniExcel&version=2.0.0-preview.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MiniExcel&version=2.0.0-preview.3&prerelease
                    
Install as a Cake Tool

MiniExcel

NuGet Version NuGet Downloads Build status Github Gitee Platform Platform Platform DeepWiki


MiniExcel is a simple and efficient Excel processing tool for .NET, specifically designed to minimize memory usage.

At present, most popular frameworks need to load all the data from an Excel document into memory to facilitate operations, but this may cause memory consumption problems. MiniExcel's approach is different: the data is processed row by row in a streaming manner, reducing the original consumption from potentially hundreds of megabytes to just a few megabytes, effectively preventing out-of-memory(OOM) issues.

image

Features

  • Minimizes memory consumption, preventing out-of-memory (OOM) errors and avoiding full garbage collections
  • Enables real-time, row-level data operations for better performance on large datasets
  • Supports LINQ with deferred execution, allowing for fast, memory-efficient paging and complex queries
  • Lightweight, without the need for Microsoft Office or COM+ components, and a size under 800KB
  • Simple and intuitive API style to import, export, and template Excel worksheets

Quickstart

Importing

You can query worksheets and map the data either to strongly typed classes or dynamic objects:

public class UserAccount
{
    public Guid ID { get; set; }
    public string Name { get; set; }
    public DateTime DateOfBirth { get; set; }
    public int Age { get; set; }
    public bool Vip { get; set; }
    public decimal Points { get; set; }
}

var userRows = MiniExcel.Query<UserAccount>(path);

// or simply

var dynamicRows = MiniExcel.Query(path);
Exporting

There are multiple ways to exprt data to an Excel document:

// From strongly typed objects

var values = new[]
{
    new { Name = "MiniExcel", Value = 1 },
    new { Name = "Github", Value = 2 }
};
MiniExcel.SaveAs(yourPath, values);


// From anonymous objects

public class TestType
{
    public string Name { get; set; }
    public int Value { get; set; }
}

TestType[] values =
[
    new TestType { Name = "MiniExcel", Value = 1 },
    new TestType { Name = "Github", Value = 2 }
];
MiniExcel.SaveAs(yourPath, values);


//From a IEnumerable<IDictionary<string, object>>

new List<Dictionary<string, object>>() dicts =
[
    new Dictionary<string, object> { { "Name", "MiniExcel" }, { "Value", 1 } },
    new Dictionary<string, object> { { "Name", "Github" }, { "Value", 2 } }
];
MiniExcel.SaveAs(yourPath, dicts);


// Directly from a IDataReader

using var connection = yourConnectionProvider.GetConnection();
connection.Open();

using var cmd = connection.CreateCommand();
cmd.CommandText = """
    SELECT 'MiniExcel' AS "Name", 1 AS "Value"
    UNION ALL
    SELECT 'Github', 2
    """;

using var reader = cmd.ExecuteReader();
MiniExcel.SaveAs(yourPath, reader);


// From a DataTable

var table = new DataTable();
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Value", typeof(int));
table.Rows.Add("MiniExcel", 1);
table.Rows.Add("Github", 2);

MiniExcel.SaveAs(path, table);
Product 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 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 is compatible.  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 is compatible.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (177)

Showing the top 5 NuGet packages that depend on MiniExcel:

Package Downloads
GuoKun.CPS

国坤CPS库

BootstrapBlazor.TableExport

Bootstrap UI components extensions of export

Dynamicweb.DataIntegration.Providers.ExcelProvider

Excel Provider

DH.MiniExcel

基于DH框架的Excel处理库。基于https://github.com/mini-software/MiniExcel

Wologic.SYS.Application

公司内部自用

GitHub repositories (17)

Showing the top 17 popular GitHub repositories that depend on MiniExcel:

Repository Stars
Scighost/Starward
Game Launcher for miHoYo - 米家游戏启动器
dotnetcore/Magicodes.IE
Import and export general library, support Dto import and export, template export, fancy export and dynamic export, support Excel, Csv, Word, Pdf and Html.
izhaorui/Zr.Admin.NET
🎉ZR.Admin.NET是一款前后端分离的、跨平台基于RBAC的通用权限管理后台。ORM采用SqlSugar。前端采用Vue、AntDesign,支持多租户、缓存、任务调度、支持统一异常处理、接口限流、支持一键生成前后端代码,支持动态国际化翻译(Vue3),等诸多黑科技,代码简洁易懂、易扩展让开发更简单、更通用。
mukunku/ParquetViewer
Simple Windows desktop application for viewing & querying Apache Parquet files
colinin/abp-next-admin
这是基于vue-vben-admin 模板适用于abp vNext的前端管理项目
xunkong/xunkong
记录旅途中发生的事
VladislavAntonyuk/MauiSamples
.NET MAUI Samples
sdcb/chats
A powerful and flexible frontend & AI gateway for large language models, supporting 21+ mainstream AI model providers.
AIDotNet/Thor
Thor is a powerful artificial intelligence model management tool, whose main purpose is to achieve unified management and use of multiple AI models. Through Thor, users can easily manage and utilize numerous AI models
zmrid/iMES-Factory
iMES工厂管家——您的新一代工厂助手。演示地址:https://imes.625sc.com。 一款基于.NetCore3.1和Vue3的MES管理系统。项目亮点:模版打印,Excel模版导出,自定义实体扩展,移动端精美设计,大屏设计等功能。
lindexi/lindexi_gd
博客用到的代码
842549829/Panda
Abp.vNext + EF Core The microservices Open source framework project supports the implementation of message push workflow certification centers based on OAuth2.0
spacechase0/StardewValleyMods
New home for my stardew valley mod source code
densen2014/BlazorMaui
用 c # 和 Razor 创建本机移动应用和桌面应用。使用 Blazor.BB.Maui,可以快速开发共享代码库运行于 Windows (Winforms/WPF/UWP)、Android、iOS、macOS 的应用。
ErrorLSC/Polars.NET
.NET DataFrame Engine
shuyu-labs/Text2Sql.Net
Text2Sql.Net 是一个使用DotNet和Semantic Kernel开发的Text2Sql工具
densen2014/Blazor100
Blazor入门100天