NanoXLSX 2.5.2

dotnet add package NanoXLSX --version 2.5.2                
NuGet\Install-Package NanoXLSX -Version 2.5.2                
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="NanoXLSX" Version="2.5.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NanoXLSX --version 2.5.2                
#r "nuget: NanoXLSX, 2.5.2"                
#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.
// Install NanoXLSX as a Cake Addin
#addin nuget:?package=NanoXLSX&version=2.5.2

// Install NanoXLSX as a Cake Tool
#tool nuget:?package=NanoXLSX&version=2.5.2                

NanoXLSX NanoXLSX

nuget license FOSSA Status

NanoXLSX is a small .NET library written in C#, to create and read Microsoft Excel files in the XLSX format (Microsoft Excel 2007 or newer) in an easy and native way

  • Minimum of dependencies (*
  • No need for an installation of Microsoft Office
  • No need for Office interop libraries
  • No need for proprietary 3rd party libraries
  • No need for an installation of the Microsoft Open Office XML SDK (OOXML)

Project website: https://picoxlsx.rabanti.ch

See the Change Log for recent updates.

What's new in version 2.x

There are some additional functions for workbooks and worksheets, as well as support of further data types. The biggest change is the full capable reader support for workbook, worksheet and style information. Also, all features are now fully unit tested. This means, that NanoXLSX is no longer in Beta status, but production ready. Some key features are:

  • Full reader support for styles, workbooks, worksheets and workbook metadata
  • Copy functions for worksheets
  • Advance import options for the reader
  • Several additional checks, exception handling and updated documentation

Road map

Version 2.x of NanoXLSX was completely overhauled and a high number of (partially parametrized) unit tests with a code coverage of >99% were written to improve the quality of the library. However, it is not planned as a LTS version. The upcoming v3.x is supposed to introduce some important functions, like in-line cell formatting, better formula handling and additional worksheet features. Furthermore, it is planned to introduce more modern OOXML features like the SHA256 implementation of worksheet passwords. One of the main aspects of this upcoming version is a better modularization, as well as the consolidation with PicoXLS to one single code base.

Reader Support

The reader of NanoXLS follows the principle of "What You Can Write Is What You Can Read". Therefore, all information about workbooks, worksheets, cells and styles that can be written into an XLSX file by NanoXLSX, can also be read by it. There are some limitations:

  • A workbook or worksheet password cannot be recovered, only its hash
  • Information that is not supported by the library will be discarded
  • There are some approximations for floating point numbers. These values (e.g. pane split widths) may deviate from the originally written values
  • Numeric values are cast to the appropriate .NET types with best effort. There are import options available to enforce specific types
  • No support of other objects than spreadsheet data at the moment
  • Due to the potential high complexity, custom number format codes are currently not automatically escaped on writing or un-escaped on reading

Requirements

NanoXLSX is originally based on PicoXLSX. However, NanoXLSX is now in the development lead, whereas PicoXLSX is a subset of it. The library is currently on compatibility level with .NET version 4.5 and .NET Standard 2.0. Newer versions should of course work as well. Older versions, like .NET 3.5 have only limited support, since newer language features were used.

.NET 4.5 or newer

*)The only requirement to compile the library besides .NET (v4.5 or newer) is the assembly WindowsBase, as well as System.IO.Compression. These assemblies are standard components in all Microsoft Windows systems (except Windows RT systems). If your IDE of choice supports referencing assemblies from the Global Assembly Cache (GAC) of Windows, select WindowsBase and Compression from there. If you want so select the DLLs manually and Microsoft Visual Studio is installed on your system, the DLL of WindowsBase can be found most likely under "c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll", as well as System.IO.Compression under "c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.IO.Compression.dll". Otherwise you find them in the GAC, under "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\WindowsBase" and "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.IO.Compression"

The NuGet package does not require dependencies

.NET Standard

.NET Standard v2.0 resolves the dependency System.IO.Compression automatically, using NuGet and does not rely anymore on WindowsBase in the development environment. In contrast to the .NET >=4.5 version, no manually added dependencies necessary (as assembly references) to compile the library.

Please note that the demo project of the .NET Standard version will not work in Visual Studio 2017. To get the build working, unload the demo project of the .NET Standard version.

Documentation project

If you want to compile the documentation project (folder: Documentation; project file: shfbproj), you need also the Sandcastle Help File Builder (SHFB). It is also freely available. But you don't need the documentation project to build the NanoXLSX library.

The .NET version of the documentation may vary, based on the installation. If v4.5 is not available, upgrade to target to a newer version, like v4.6

Utility dependencies

The Test project and GitHub Actions may also require dependencies like unit testing frameworks or workflow steps. However, none of these dependencies are essential to build the library. They are just utilities. The test dependencies ensure efficient unit testing and code coverage. The GitHub Actions dependencies are used for the automatization of releases and API documentation

Installation

Using NuGet

By package Manager (PM):

Install-Package NanoXLSX

By .NET CLI:

dotnet add package NanoXLSX

As DLL

Simply place the NanoXLSX DLL into your .NET project and add a reference to it. Please keep in mind that the .NET version of your solution must match with the runtime version of the NanoXLSX DLL (currently compiled with 4.5 and .NET Standard 2.0).

As source files

Place all .CS files from the NanoXLSX source folder and its sub-folders into your project. In case of the .NET >=4.5 version, the necessary dependencies have to be referenced as well.

Usage

Quick Start (shortened syntax)

 Workbook workbook = new Workbook("myWorkbook.xlsx", "Sheet1");         // Create new workbook with a worksheet called Sheet1
 workbook.WS.Value("Some Data");                                        // Add cell A1
 workbook.WS.Formula("=A1");                                            // Add formula to cell B1
 workbook.WS.Down();                                                    // Go to row 2
 workbook.WS.Value(DateTime.Now, Style.BasicStyles.Bold);               // Add formatted value to cell A2
 workbook.Save();                                                       // Save the workbook as myWorkbook.xlsx

Quick Start (regular syntax)

 Workbook workbook = new Workbook("myWorkbook.xlsx", "Sheet1");         // Create new workbook with a worksheet called Sheet1
 workbook.CurrentWorksheet.AddNextCell("Some Data");                    // Add cell A1
 workbook.CurrentWorksheet.AddNextCell(42);                             // Add cell B1
 workbook.CurrentWorksheet.GoToNextRow();                               // Go to row 2
 workbook.CurrentWorksheet.AddNextCell(DateTime.Now);                   // Add cell A2
 workbook.Save();                                                       // Save the workbook as myWorkbook.xlsx

Quick Start (read)

 Workbook wb = Workbook.Load("basic.xlsx");                             // Read the workbook
 System.Console.WriteLine("contains worksheet name: " + wb.CurrentWorksheet.SheetName);
 foreach (KeyValuePair<string, Cell> cell in wb.CurrentWorksheet.Cells)
 {
    System.Console.WriteLine("Cell address: " + cell.Key + ": content:'" + cell.Value.Value + "'");
 }

Further References

See the full API-Documentation at: https://rabanti-github.github.io/NanoXLSX/.

The demo project contains 18 simple use cases. You can find also the full documentation in the Documentation-Folder (html files or single chm file) or as C# documentation in the particular .CS files.

Note: The demo project of the .NET Standard version is identical and only links to the .NET >=4.5 version files.

See also: Getting started in the Wiki

Hint: You will find most certainly any function, and the way how to use it, in the Unit Test Project

License

FOSSA Status

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. 
.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 net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  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 (2)

Showing the top 2 NuGet packages that depend on NanoXLSX:

Package Downloads
HighbornBD

Sistema simples de banco de dados pra codigos VB e C#

MaxRunSoftware.Utilities.Data.Excel

Various helper methods and functions for data manipulation such as SQL and CSV files

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.5.2 1,809 11/24/2024
2.5.1 2,109 10/25/2024
2.5.0 11,848 7/22/2024
2.4.0 17,422 4/21/2024
2.3.3 3,764 2/24/2024
2.3.1 8,805 1/22/2024
2.3.0 12,268 9/7/2023
2.2.0 22,751 4/23/2023
2.1.1 7,667 3/4/2023
2.1.0 46,706 11/8/2022
2.0.4 3,204 10/4/2022
2.0.3 518 10/1/2022
2.0.2 393 9/29/2022
2.0.1 1,112 9/10/2022
2.0.0 542 9/3/2022
1.8.7 3,034 8/6/2022
1.8.6 2,418 4/1/2022
1.8.5 813 3/26/2022
1.8.4 4,006 3/20/2022
1.8.3 1,131 3/10/2022
1.8.2 6,783 12/20/2021
1.8.1 1,933 9/12/2021
1.8.0 2,064 7/9/2021
1.7.0 582 6/5/2021
1.6.0 595 4/18/2021
1.5.0 851 12/10/2020
1.4.1 667 9/13/2020
1.4.0 549 8/30/2020
1.3.6 552 7/19/2020
1.3.5 2,141 1/12/2020
1.3.4 581 12/1/2019
1.3.3 918 5/20/2019
1.3.2 875 12/8/2018
1.3.1 751 11/4/2018
1.3.0 933 10/6/2018
1.2.4 806 8/24/2018
1.2.3 867 8/24/2018