FluentNPOI 2.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FluentNPOI --version 2.2.0
                    
NuGet\Install-Package FluentNPOI -Version 2.2.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="FluentNPOI" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentNPOI" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="FluentNPOI" />
                    
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 FluentNPOI --version 2.2.0
                    
#r "nuget: FluentNPOI, 2.2.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.
#:package FluentNPOI@2.2.0
                    
#: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=FluentNPOI&version=2.2.0
                    
Install as a Cake Addin
#tool nuget:?package=FluentNPOI&version=2.2.0
                    
Install as a Cake Tool

FluentNPOI

CI .NET Standard 2.0 License: MIT

FluentNPOI 是基於 NPOI 的流暢(Fluent)風格 Excel 操作庫,提供更直觀、更易用的 API 來讀寫 Excel 文件。

English | 繁體中文


繁體中文

🚀 特性

  • 流暢 API - 支援鏈式調用,代碼更簡潔易讀
  • 強型別映射 - 透過 FluentMapping 進行強型別資料綁定與樣式設定
  • 模組化套件 - 按需安裝:核心、PDF、串流、圖表
  • 直觀樣式 - 支援在 Mapping 中直接設定樣式,或使用 FluentCell API 進行細粒度控制
  • 樣式管理 - 智能樣式緩存機制,自動處理重複樣式
  • 完整讀寫 - 支援讀寫 Excel、圖片插入、公式設定、合併儲存格
  • HTML/PDF 匯出 - 將 Excel 轉換為 HTML 或 PDF
  • 圖表產生 - 使用 ScottPlot 產生圖表並嵌入 Excel

📦 安裝

核心套件
dotnet add package FluentNPOI
可選模組
套件 用途 安裝
FluentNPOI.Pdf PDF 匯出 (QuestPDF) dotnet add package FluentNPOI.Pdf
FluentNPOI.Streaming 大檔案串流讀寫 dotnet add package FluentNPOI.Streaming
FluentNPOI.Charts 圖表產生 (ScottPlot) dotnet add package FluentNPOI.Charts
FluentNPOI.All 完整功能 (包含所有模組) dotnet add package FluentNPOI.All

🎯 快速開始

1. 基本讀寫
using FluentNPOI;
using NPOI.XSSF.UserModel;

var workbook = new XSSFWorkbook();
var fluent = new FluentWorkbook(workbook);

fluent.UseSheet("Sheet1")
      .SetCellPosition(ExcelCol.A, 1)
      .SetValue("Hello World!")
      .SetBackgroundColor(IndexedColors.Yellow)
      .SetFont(isBold: true, fontSize: 14);

fluent.SaveToPath("output.xlsx");
2. 強型別表格綁定 (推薦)
var mapping = new FluentMapping<Student>();

mapping.Map(x => x.Name)
    .ToColumn(ExcelCol.A)
    .WithTitle("姓名")
    .WithBackgroundColor(IndexedColors.LightCornflowerBlue);

mapping.Map(x => x.Score)
    .ToColumn(ExcelCol.B)
    .WithTitle("分數")
    .WithNumberFormat("0.0");

fluent.UseSheet("Report")
      .SetTable(data, mapping)
      .BuildRows()
      .SetAutoFilter()
      .FreezeTitleRow();
3. 串流處理大檔案
using FluentNPOI.Streaming;

StreamingBuilder<DataModel>.FromFile("large_input.xlsx")
    .Transform(x => x.Value *= 2)
    .WithMapping(mapping)
    .SaveAs("output.xlsx");
4. 圖表產生
using FluentNPOI.Charts;

// 整合串鍊 API
fluent.UseSheet("Charts")
    .SetCellPosition(ExcelCol.A, 1)
    .AddBarChart(data, chart => {
        chart.X(d => d.Category)
             .Y(d => d.Value)
             .WithTitle("Sales Report");
    }, width: 400, height: 300);

// 或手動產生
var chartBytes = ChartBuilder.Bar(data)
    .X(d => d.Category)
    .Y(d => d.Value)
    .Configure(plot => {
        // 完整存取 ScottPlot API
        plot.FigureBackground.Color = ScottPlot.Colors.White;
    })
    .ToPng(400, 300);
5. PDF 匯出
using FluentNPOI.Pdf;

PdfConverter.ConvertSheetToPdf(fluent.UseSheet("Report"), "report.pdf");

📖 API 概覽

用途 主要方法
Mapping Map, ToColumn, WithTitle, WithNumberFormat, WithBackgroundColor
Cell SetValue, SetFormula, SetBackgroundColor, SetBorder, SetFont
Table SetTable, BuildRows, SetAutoFilter, FreezeTitleRow, AutoSizeColumns
Streaming StreamingBuilder.FromFile, Transform, SaveAs
Charts AddBarChart, AddLineChart, AddPieChart, ChartBuilder

English

🚀 Features

  • Fluent API - Chained method calls for simpler, readable code
  • Strongly Typed Mapping - Use FluentMapping for type-safe data binding
  • Modular Packages - Install only what you need: Core, PDF, Streaming, Charts
  • Direct Styling - Configure styles directly within Mapping or FluentCell API
  • Style Management - Smart caching to handle duplicate styles
  • Comprehensive I/O - Read/Write, Images, Formulas, Merging
  • HTML/PDF Export - Convert Excel to HTML or PDF
  • Chart Generation - Generate charts using ScottPlot and embed in Excel

📦 Installation

Core Package
dotnet add package FluentNPOI
Optional Modules
Package Purpose Install
FluentNPOI.Pdf PDF Export (QuestPDF) dotnet add package FluentNPOI.Pdf
FluentNPOI.Streaming Large File Streaming dotnet add package FluentNPOI.Streaming
FluentNPOI.Charts Chart Generation (ScottPlot) dotnet add package FluentNPOI.Charts
FluentNPOI.All Full Features (All modules) dotnet add package FluentNPOI.All

🎯 Quick Start

1. Basic Write
using FluentNPOI;
using NPOI.XSSF.UserModel;

var workbook = new XSSFWorkbook();
var fluent = new FluentWorkbook(workbook);

fluent.UseSheet("Sheet1")
      .SetCellPosition(ExcelCol.A, 1)
      .SetValue("Hello World!")
      .SetBackgroundColor(IndexedColors.Yellow)
      .SetFont(isBold: true, fontSize: 14);

fluent.SaveToPath("output.xlsx");
var mapping = new FluentMapping<Student>();

mapping.Map(x => x.Name)
    .ToColumn(ExcelCol.A)
    .WithTitle("Name")
    .WithBackgroundColor(IndexedColors.LightCornflowerBlue);

mapping.Map(x => x.Score)
    .ToColumn(ExcelCol.B)
    .WithTitle("Score")
    .WithNumberFormat("0.0");

fluent.UseSheet("Report")
      .SetTable(data, mapping)
      .BuildRows()
      .SetAutoFilter()
      .FreezeTitleRow();
3. Streaming for Large Files
using FluentNPOI.Streaming;

StreamingBuilder<DataModel>.FromFile("large_input.xlsx")
    .Transform(x => x.Value *= 2)
    .WithMapping(mapping)
    .SaveAs("output.xlsx");
4. Chart Generation
using FluentNPOI.Charts;

// Integrated chaining API
fluent.UseSheet("Charts")
    .SetCellPosition(ExcelCol.A, 1)
    .AddBarChart(data, chart => {
        chart.X(d => d.Category)
             .Y(d => d.Value)
             .WithTitle("Sales Report");
    }, width: 400, height: 300);

// Or generate manually
var chartBytes = ChartBuilder.Bar(data)
    .X(d => d.Category)
    .Y(d => d.Value)
    .Configure(plot => {
        // Full access to ScottPlot API
        plot.FigureBackground.Color = ScottPlot.Colors.White;
    })
    .ToPng(400, 300);
5. PDF Export
using FluentNPOI.Pdf;

PdfConverter.ConvertSheetToPdf(fluent.UseSheet("Report"), "report.pdf");

📖 API Overview

Area Key Methods
Mapping Map, ToColumn, WithTitle, WithNumberFormat, WithBackgroundColor
Cell SetValue, SetFormula, SetBackgroundColor, SetBorder, SetFont
Table SetTable, BuildRows, SetAutoFilter, FreezeTitleRow, AutoSizeColumns
Streaming StreamingBuilder.FromFile, Transform, SaveAs
Charts AddBarChart, AddLineChart, AddPieChart, ChartBuilder

🤝 Contribution

Issues and Pull Requests are welcome!

📄 License

MIT License - See LICENSE file.

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 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 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 (5)

Showing the top 5 NuGet packages that depend on FluentNPOI:

Package Downloads
FluentNPOI.All

Complete FluentNPOI package bundle including all extension modules (PDF, Streaming, Charts).

FluentNPOI.Charts

Chart generation extension for FluentNPOI using ScottPlot.

FluentNPOI.Pdf

PDF export extension for FluentNPOI using QuestPDF.

FluentNPOI.Streaming

Streaming read extension for FluentNPOI using ExcelDataReader for large file processing.

FluentNPOI.HotReload

Hot Reload extension for FluentNPOI with declarative widget-based Excel development and LibreOffice live preview support.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 376 12/24/2025
2.2.0 325 12/20/2025
2.1.0 214 12/19/2025
2.0.1 248 12/19/2025
2.0.0 252 12/19/2025
1.2.1 206 12/5/2025
1.2.0 210 12/5/2025
1.1.0 201 12/4/2025
1.0.1 599 12/1/2025
1.0.0 588 12/1/2025