NkkinXlsx 1.0.1

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

NkkinXlsx

NkkinXlsx is a dependency-free .xlsx library for .NET 10 and .NET 11 (Android, iOS, Windows, Linux, macOS; trimming- and AOT-safe).

Use 1.0.1 or later: 1.0.0 required apps to enable preview features. It reads and writes spreadsheet packages directly with the .NET ZIP and XML APIs. Native legacy binary .xls creation is not supported.

Install

dotnet add package NkkinXlsx --version 1.0.1

Quick start

using NkkinXlsx;

var workbook = new Workbook();
var sheet = workbook.AddWorksheet("Sales");
sheet.SetValue("A1", "Region");
sheet.SetValue("B1", "Revenue");
sheet.SetValue("A2", "North");
sheet.SetValue("B2", 1250.50);
sheet.SetFormula("B3", "SUM(B2:B2)", cachedValue: 1250.50);

sheet["A1"].Style = new CellStyle(Bold: true, FillColor: "D9EAF7");
sheet.SetAutoFilter("A1:B2");
sheet.AddTable("SalesTable", "A1:B2");
sheet.AddBarChart("Revenue by region", "A2:A2", "B2:B2", "D2");
sheet.AddPivotTable("RevenueByRegion", "A1:B2", "F1",
    ["Region"], new PivotValueField("Revenue", Aggregation: PivotAggregation.Sum));
workbook.Save("sales.xlsx");

var reopened = Workbook.Open("sales.xlsx");
Console.WriteLine(reopened.GetWorksheet("Sales")["B2"].Value);

sheet.SaveCsv("sales.csv");

Save(Stream) and Open(Stream) are also available for XLSX. Worksheet.SaveCsv(Stream) writes CSV and leaves the stream open. CSV defaults to comma-separated UTF-8 with a BOM (for Excel compatibility), invariant numeric values, ISO 8601 dates, and a used-cell range; pass a range or CsvOptions to customize the export.

For rectangular data sets, use SetValues to write a two-dimensional array starting at one cell instead of formatting and parsing an address for every value:

object?[,] rows =
{
    { "Region", "Revenue" },
    { "North", 1250.50 },
    { "South", 980.00 }
};
sheet.SetValues("A1", rows);

When source rows are produced incrementally, SetRows consumes them once without requiring a full two-dimensional input array:

IEnumerable<object?[]> ReadRows()
{
    yield return ["Region", "Revenue"];
    yield return ["North", 1250.50];
    yield return ["South", 980.00];
}

sheet.SetRows("A1", ReadRows());

Both bulk APIs accept the same cell value types as SetValue, enforce Excel's worksheet bounds, preserve existing styles, and replace formulas in overwritten cells. SetRows requires rows of equal width. It avoids materializing a separate full input matrix, but the worksheet retains its cells in memory until the workbook is saved.

Current capabilities

  • Text is stored exactly: characters XML can't hold (control characters, unpaired surrogates) use Excel's _xHHHH_ escapes, and cells longer than Excel's 32,767-character limit are refused on save.

  • Create, read, and edit cell values and formulas, including cached formula values.

  • Write rectangular object[,] data in bulk from a starting cell.

  • Ingest equal-width rows from an enumerable without requiring a full input matrix.

  • Export a worksheet to CSV, including quoted commas/quotes/newlines, custom delimiters, and range selection. Formula cells export their cached values; formulas aren't calculated.

  • Basic font, fill, alignment, and number-format styles.

  • Worksheet auto-filters and table creation.

  • Column bar charts and embedded PNG, JPEG, GIF, or BMP images on newly created sheets.

  • Native worksheet pivot-table definitions and cached source records, with row fields and Sum, Count, Average, Min, or Max aggregations.

  • Worksheet protection using Excel's legacy password hash.

  • No NuGet runtime dependencies.

The reader currently imports worksheet names, cell values, formulas, simple styles, and worksheet auto-filter ranges. It does not preserve or import existing tables, charts, images, protection settings, macros, pivot tables, external links, or other unsupported package parts when a workbook is opened and saved. Use it for supported-content workbooks only; do not use it to round-trip complex files that must retain unsupported features.

The same worksheet data can be exported as XLSX or CSV. PDF remains intentionally outside this package so applications can use their existing PDF library without adding a PDF dependency here. Pivot tables are generated from a source range on the same worksheet and placed at a non-overlapping destination. They carry a refreshable cache; formulas are stored as formula text and are not calculated. Pivot output rendering/refresh is left to spreadsheet applications. Worksheet protection is not file encryption and does not provide strong access control. Conditional formatting, sorting, merged cells, and full Excel feature compatibility are not implemented yet.

CSV text that starts with a formula marker (=, +, -, or @, including after leading whitespace) is prefixed with an apostrophe by default to reduce spreadsheet formula-injection risk. Set EscapeFormulaLikeText = false only when the exported content is trusted and the original text must be kept verbatim.

Performance

The writer streams worksheet XML directly to the ZIP package rather than building a second full worksheet XML tree in memory. It deduplicates ordinary text through the XLSX shared-string table and uses balanced ZIP compression for XML. There are no third-party dependencies.

Comparative benchmark (Windows x64)

Measured on .NET 10.0.13, Windows 11 x64, Intel Core i3-8100 @ 3.60 GHz, with 30,000 data rows × 8 columns. Data contains repeated labels, unique text, integers, decimals, dates, and booleans. Each writer was populated before timing, warmed with one save, then saved seven times to memory; the table reports median save time and process-wide allocated bytes during save. Generated workbooks were independently opened and checked for dimensions and representative values.

Library Version Main DLL Median save Allocated during save XLSX size
NkkinXlsx 0.2.1 94 KiB 374 ms 38.2 MiB 1,358,443 bytes
EPPlus 8.7.2 4,460 KiB 589 ms 124.9 MiB 1,374,689 bytes
ClosedXML 0.105.1 1,661 KiB 1,320 ms 226.5 MiB 1,428,448 bytes
MiniExcel 1.46.0 416 KiB 375 ms 102.9 MiB 2,685,505 bytes

For this workload, NkkinXlsx's default-style XML optimization reduced its output from 1,413,575 bytes to 1,358,443 bytes (3.9% smaller) compared with the earlier run. EPPlus produced a 1.2% larger file in this run. Save-time medians vary between runs: NkkinXlsx was about 36% faster than EPPlus and about 3.5× faster than ClosedXML, while MiniExcel was about 1 ms slower than NkkinXlsx. NkkinXlsx allocated about 69% less during save than EPPlus and 83% less than ClosedXML. MiniExcel's output was about 98% larger.

Real Android device benchmark

The same typed 8-column dataset was also exported on a connected OPPO CPH2599 (Android 16, .NET 10 Release build, trimming/AOT disabled for the comparison). This device run used 10,000 rows, one warm-up, then three timed saves; values below are medians. The APK wrote the files on-device and checked NkkinXlsx save/reopen plus CSV output.

Library Main DLL Median save Allocated during save XLSX size
NkkinXlsx 0.2.1 94 KiB 295 ms 13.1 MiB 450,176 bytes
EPPlus 8.7.2 4,460 KiB 586 ms 44.4 MiB 468,148 bytes
ClosedXML 0.105.1 1,661 KiB 2,093 ms 76.0 MiB 467,922 bytes
MiniExcel 1.46.0 416 KiB 308 ms 48.0 MiB 664,223 bytes

On this device and workload, the optimized NkkinXlsx file is about 3.8% smaller than EPPlus's. NkkinXlsx was about 4% faster than MiniExcel; MiniExcel's output was about 48% larger. It was about 50% faster than EPPlus and allocated about 70% less during save. These results are device-specific.

Bulk input population

SetValues avoids parsing a cell address for every value. The following setup measurements used the same prebuilt 2D array, created a workbook and worksheet, inserted all values, and applied the same date format. Input-array construction is excluded; values are medians of seven Windows runs and three Android runs.

Platform / workload Input API Median population Allocation
Windows 11 x64 / 30,001 × 8 including header Per-cell SetValue 286 ms 188.6 MiB
Windows 11 x64 / 30,001 × 8 including header Bulk SetValues 129 ms 45.7 MiB
Windows 11 x64 / 30,001 × 8 including header Streaming SetRows 159 ms 48.2 MiB
OPPO CPH2599, Android 16 / 10,001 × 8 including header Per-cell SetValue 297 ms 71.9 MiB
OPPO CPH2599, Android 16 / 10,001 × 8 including header Bulk SetValues 68 ms 20.1 MiB
OPPO CPH2599, Android 16 / 10,001 × 8 including header Streaming SetRows 70 ms 21.1 MiB

These runs projected each row from a prebuilt source matrix; the SetRows row-array projection was included in its time and allocation measurement, while source matrix creation was excluded. SetRows was slower than SetValues in this test, which has the simpler prebuilt-array input. Its benefit is avoiding a separately materialized complete input matrix when the application can produce rows lazily. Neither bulk API makes workbook storage itself streaming: the worksheet still retains all populated cells until save. The per-cell/SetValues/SetRows comparisons were not cross-compared against competitor population APIs.

Library Direct NuGet package Resolved dependency package closure
NkkinXlsx 0.2.1 51 KiB 51 KiB, no third-party packages
EPPlus 16,418 KiB 20,397 KiB / 14 packages
ClosedXML 2,063 KiB 15,823 KiB / 8 packages
MiniExcel 976 KiB 976 KiB / 1 package

Main DLL sizes in both benchmark tables are the primary library assemblies from the resolved NuGet packages; they are not total application size. Package footprint is based on compressed NuGet .nupkg archives; dependency closure sums the resolved packages for the benchmark's .NET 10 target. It is not a measurement of a trimmed application APK. EPPlus was run with its noncommercial personal license mode for this local benchmark only; this does not grant commercial-use rights.

These are serialization-focused comparisons, not complete application benchmarks: workbook/data-object construction is excluded, there is no styling beyond the common date number format, and formulas/tables/charts are excluded. Timings vary by machine, runtime, and data; a different API/input representation can affect allocation results. This is not a claim that NkkinXlsx is faster for every workload or feature set.

The reproducible desktop harness uses the versions above, warms up each writer, reports the median of seven saves, outputs one sample workbook per library, and prints package sizes:

dotnet pack .\NkkinXlsx\NkkinXlsx.csproj --configuration Release
dotnet run --project .\NkkinXlsx.Benchmarks\NkkinXlsx.Benchmarks.csproj --configuration Release -- --rows 30000 --iterations 7

EPPlus benchmarks use a noncommercial personal license mode. Respect EPPlus licensing terms and use a commercial license where required.

Build and smoke test

dotnet build .\NkkinXlsx.slnx
dotnet run --project .\NkkinXlsx.SmokeTests\NkkinXlsx.SmokeTests.csproj

Android device smoke test

The optional Android harness is kept outside the core solution so library builds do not require the Android workload. With Android SDK tools on PATH and a USB-debugging-enabled device connected, run:

dotnet build .\NkkinXlsx.DeviceSmokeTest\NkkinXlsx.DeviceSmokeTest.csproj --configuration Release
adb install -r .\NkkinXlsx.DeviceSmokeTest\bin\Release\net10.0-android\com.nkkin.xlsx.devicesmoketest-Signed.apk
adb logcat -c
adb shell monkey -p com.nkkin.xlsx.devicesmoketest -c android.intent.category.LAUNCHER 1
Start-Sleep -Seconds 10
adb logcat -d -s NkkinXlsxDeviceTest

The harness writes and reopens a 10,000-row XLSX, exports CSV, checks representative values and output rows, and logs a device-specific PASS/FAIL report. Generated test files are stored in the harness app's private data directory.

Building and publishing

build-pack.cmd (Windows) runs the smoke tests on net10.0 and net11.0, then packs to artifacts/nuget. Elsewhere (needs the .NET 11 SDK):

dotnet run --project NkkinXlsx.SmokeTests -c Release -f net10.0
dotnet run --project NkkinXlsx.SmokeTests -c Release -f net11.0
dotnet pack NkkinXlsx/NkkinXlsx.csproj -c Release -o artifacts/nuget
dotnet nuget push artifacts/nuget/NkkinXlsx.<version>.nupkg --api-key <key> --source https://api.nuget.org/v3/index.json

The matching .snupkg is uploaded to the symbol server automatically.

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

    • No dependencies.
  • net11.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
1.0.1 86 11/16/2026
1.0.0 94 11/13/2026
0.2.2 102 11/10/2026
0.1.0 104 11/4/2026

1.0.1: no longer requires preview features (1.0.0 marked the assembly [RequiresPreviewFeatures], so apps failed to compile with CA2252). Fixes: text with control characters or unpaired surrogates no longer makes Save throw (written with Excel's _xHHHH_ escapes, decoded on read); text that looks like an escape stays literal in Excel; numbers with formats such as [Red]0.00, "USD" or [$-409] no longer read back as dates; cells over Excel's 32,767-character limit are refused on save with the cell address; sheet names with control characters are refused. Reader: streams worksheets and shared strings (about 3x faster and 4x less memory on large files), reads cells and rows without references, inline rich text, ISO date cells, and skips phonetic guide text. Same API as 1.0.0.
1.0.0: net10.0 + net11.0 targets.
0.2.x: trim- and AOT-compatible; SetRows for row enumeration; deterministic builds with snupkg symbols.