CommonNetFuncs.Excel.OpenXml
4.1.5
dotnet add package CommonNetFuncs.Excel.OpenXml --version 4.1.5
NuGet\Install-Package CommonNetFuncs.Excel.OpenXml -Version 4.1.5
<PackageReference Include="CommonNetFuncs.Excel.OpenXml" Version="4.1.5" />
<PackageVersion Include="CommonNetFuncs.Excel.OpenXml" Version="4.1.5" />
<PackageReference Include="CommonNetFuncs.Excel.OpenXml" />
paket add CommonNetFuncs.Excel.OpenXml --version 4.1.5
#r "nuget: CommonNetFuncs.Excel.OpenXml, 4.1.5"
#:package CommonNetFuncs.Excel.OpenXml@4.1.5
#addin nuget:?package=CommonNetFuncs.Excel.OpenXml&version=4.1.5
#tool nuget:?package=CommonNetFuncs.Excel.OpenXml&version=4.1.5
CommonNetFuncs.Excel.OpenXml
This project contains helper methods for reading and writing Excel files using the OpenXML SDK in .NET applications.
Contents
Common
Low-level helpers for building and manipulating SpreadsheetDocument objects with the OpenXML SDK. Covers creating workbooks and sheets, reading and writing cell values, managing number formats, inserting images, applying cell styles, and finalizing documents.
Common Usage Examples
<details> <summary><h3>Usage Examples</h3></summary>
InitializeExcelFile / CreateNewSheet
using DocumentFormat.OpenXml.Packaging;
using CommonNetFuncs.Excel.OpenXml;
using MemoryStream ms = new();
using SpreadsheetDocument document = SpreadsheetDocument.Create(ms, SpreadsheetDocumentType.Workbook, true);
uint sheetId = document.InitializeExcelFile("Sheet1"); // creates the workbook and first sheet
uint sheet2Id = document.CreateNewSheet("Sheet2"); // appends a second sheet
Worksheet? ws = document.GetWorksheetById(sheetId);
WriteAndClose / WriteAndCloseAsync
WriteAndClose saves the workbook, disposes the document, and resets the stream position to 0 so the stream is ready to be read or returned immediately.
Use the single-Stream overload when the document was created in-memory:
using DocumentFormat.OpenXml.Packaging;
using CommonNetFuncs.Excel.OpenXml;
using MemoryStream ms = new();
SpreadsheetDocument document = SpreadsheetDocument.Create(ms, SpreadsheetDocumentType.Workbook);
document.InitializeExcelFile("Sheet1");
// ... write data ...
document.WriteAndClose(ms); // saves, disposes, resets ms.Position to 0
// ms is now ready to read / return as a file download
Use the filePath overload (or its async counterpart) when the document was created against a file path and you want to return the result as a MemoryStream:
using DocumentFormat.OpenXml.Packaging;
using CommonNetFuncs.Excel.OpenXml;
string path = Path.GetTempFileName();
MemoryStream ms = new();
SpreadsheetDocument document = SpreadsheetDocument.Create(path, SpreadsheetDocumentType.Workbook);
document.InitializeExcelFile("Sheet1");
// ... write data ...
// sync
document.WriteAndClose(ms, path);
// async
await document.WriteAndCloseAsync(ms, path);
// ms.Position == 0 and contains the full .xlsx content
return File(ms, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "output.xlsx");
</details>
Export
Provides a GenericExcelExport extension method that converts any IEnumerable<T> into a .xlsx MemoryStream using the OpenXML SDK directly. Supports optional table formatting, custom sheet and table names, and column exclusion.
Export Usage Examples
<details> <summary><h3>Usage Examples</h3></summary>
GenericExcelExport
using CommonNetFuncs.Excel.OpenXml;
List<MyRecord> data = GetData();
// Basic export
MemoryStream? stream = data.GenericExcelExport();
// Export as a formatted Excel table, skipping a column
MemoryStream? stream = data.GenericExcelExport(
createTable: true,
sheetName: "Report",
tableName: "ReportTable",
skipColumnNames: ["InternalId"]
);
// Return as a file download from an ASP.NET Core endpoint
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "report.xlsx");
</details>
Installation
Install via NuGet:
dotnet add package CommonNetFuncs.Excel.OpenXml
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions 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. |
-
net10.0
- CommonNetFuncs.Core (>= 4.1.0)
- CommonNetFuncs.Excel.Common (>= 4.1.0)
- DocumentFormat.OpenXml (>= 3.5.1)
- System.Security.Cryptography.Xml (>= 10.0.9)
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 |
|---|---|---|
| 4.1.5 | 69 | 6/10/2026 |
| 4.1.3 | 91 | 6/9/2026 |
| 4.1.0 | 92 | 6/5/2026 |
| 4.0.53 | 107 | 5/28/2026 |
| 4.0.51 | 109 | 5/27/2026 |
| 4.0.50 | 104 | 5/26/2026 |
| 4.0.47 | 107 | 5/18/2026 |
| 4.0.46 | 102 | 5/15/2026 |
| 4.0.45 | 96 | 5/15/2026 |
| 4.0.44 | 93 | 5/15/2026 |
| 4.0.43 | 94 | 5/14/2026 |
| 4.0.40 | 104 | 5/10/2026 |
| 4.0.39 | 109 | 5/10/2026 |
| 4.0.37 | 112 | 5/9/2026 |
| 4.0.36 | 96 | 5/8/2026 |
| 4.0.31 | 120 | 4/21/2026 |
| 4.0.30 | 103 | 4/20/2026 |
| 4.0.29 | 101 | 4/20/2026 |
| 4.0.28 | 104 | 4/19/2026 |