ClosedXML 0.97.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package ClosedXML --version 0.97.0                
NuGet\Install-Package ClosedXML -Version 0.97.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="ClosedXML" Version="0.97.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ClosedXML --version 0.97.0                
#r "nuget: ClosedXML, 0.97.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.
// Install ClosedXML as a Cake Addin
#addin nuget:?package=ClosedXML&version=0.97.0

// Install ClosedXML as a Cake Tool
#tool nuget:?package=ClosedXML&version=0.97.0                

Release 0.97 - Laying foundation

See full list of changes at https://github.com/ClosedXML/ClosedXML/milestone/17?closed=1

Breaking changes

  • Methods that were depending on the System.Common.Drawing were removed (use another overload):
    • IXLPictures.AddPicture(Bitmap bitmap)
    • IXLPictures.AddPicture(Bitmap bitmap, String name)
    • IXLWorksheet.AddPicture(Bitmap bitmap)
    • IXLWorksheet.AddPicture(Bitmap bitmap, string name)
  • Date/time formulas (NOW(), HOUR()...) returns serial date-time, cell is no longer implicitly XLDataType.DateTime or XLDataType.TimeSpan. The DataType has to be set explicitely.
  • CalcEngine can now return XLError on error, not a CalcEngineException exception.

Improvements

System.Drawing.Common removal (#1805)

We have removed a System.Drawing.Common dependency, it was deprecated and throws runtime exception when called on non-windows environments. All complexity has been hidden behind an interface IXLGraphicEngine and a default implementation DefaultGraphicEngine in the `ClosedXML.Graphics namespace. The default engine uses SixLabors.Fonts library for font measurements. You can read more on the Graphic Engine wiki page.

On non-windows environment, it will be necessary to specify a default font. Use this code

// All workbooks created later will use the engine with a fallback font DejaVu Sans
LoadOptions.DefaultGraphicsEngine = new DefaultGraphicEngine("DejaVu Sans"); // or Tahoma or any other font that is installed

Use XLParser to parse formulas

ClosedXML has used a handcrafted parser for a while. The parse could parse a simple formulas, but a lot of features were out of its grasp (e.g. arrays, references to other worksheets, operations on references and so much more). We have replaced the original the original parser with the XLParser to facilitate a more powerful formulas.

You can try the parsing yourself on an online demo page: https://xlparser.perfectxl.nl/demo/

Through slower than the original parser, we are working with upstream to improve performance (https://github.com/spreadsheetlab/XLParser/issues/163, https://github.com/spreadsheetlab/XLParser/issues/161). Not-so-close future of CalcEngine is also multi threaded.

CalcEngine redesign

CalcEngine has been half-rewritten. It can now correctly represent all Excel types (e.g. Error is now a value, not an an exception) and perform operations on them (e.g. reference unions, comparisons work as they should).

As an example, SUM of two areas that overlap should count overlapping cells twice, thus the result should be 12, not 9.

using var wb = new XLWorkbook();
var ws = wb.AddWorksheet();
ws.Range(1, 1, 3, 3).SetValue(1);
var sum = ws.Evaluate("SUM((A1:B3,B1:C3))");
Console.WriteLine($"Result of a SUM function: {sum}");

Result of a SUM function: 12

image

A major change has been implicit intersections in the semantic of 2019 excel (Excel 2021 and 365 already support dynamic array formulas):

using var wb = new XLWorkbook();
var ws = wb.AddWorksheet();
ws.Cell("A1").SetValue(0);
ws.Cell("A2").SetValue(Math.PI / 4);
ws.Cell("A3").SetValue(Math.PI / 2);

var c1 = ws.Cell("C1");
c1.FormulaA1 = "SIN(A1:A3)";
var c2 = ws.Cell("C2");
c2.FormulaA1 = "SIN(A1:A3)";
var c3 = ws.Cell("C3");
c3.FormulaA1 = "SIN(A1:A3)";

Console.WriteLine($"C1: {c1.Value} C2: {c2.Value} C3: {c3.Value}");

C1: 0 C2: 0.7071067811865472 C3: 1

XLWorksheet.Evaluate functions now have an optional parameters to specify a context where is formula evaluated. If formula requires a context and it is missing, it will throw a MissingContextException.

using var wb = new XLWorkbook();
var ws = wb.AddWorksheet();
var row = ws.Evaluate("ROW()", "A3"); // Needs A3 for the context, otherwise MissingContextException
Console.WriteLine($"Result of a ROW function: {row}");

Add ROW #1851 and COLUMN # 1818 functions

We have added a support for ROW and COLUMN functions. They even return arrays (e.g. formula ROW(A2:D4) return {2;3;4}) , though it is difficult to see due to half revamped of CalcEngine.

using var wb = new XLWorkbook();
var ws = wb.AddWorksheet();
var sum = ws.Evaluate("SUM(COLUMN(B1:D2))");
Console.WriteLine($"Result: {sum}");

Result: 9

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

Showing the top 5 NuGet packages that depend on ClosedXML:

Package Downloads
ClosedXML.Report

ClosedXML.Report is a tool for report generation and data analysis in .NET applications through the use of Microsoft Excel. ClosedXML.Report is a .NET-library for report generation Microsoft Excel without requiring Excel to be installed on the machine that's running the code.

CsvHelper.Excel.Core

An implementation of ICsvParser and ICsvSerializer from CsvHelper that reads and writes using the ClosedXml library.

ClosedXML.Extensions.Mvc

MVC extensions for ClosedXML

ClosedXML.Extensions.WebApi

WebApi extensions for ClosedXML

SanteDB.BI

SanteDB Business Intelligence (BI) core logic. Provides structures for data sources, queries, reports, and report controls rendered in all SanteDB software solutions.

GitHub repositories (34)

Showing the top 5 popular GitHub repositories that depend on ClosedXML:

Repository Stars
nopSolutions/nopCommerce
ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
mini-software/MiniExcel
Fast, Low-Memory, Easy Excel .NET helper to import/export/template spreadsheet (support Linux, Mac)
serenity-is/Serenity
Business Apps Made Simple with Asp.Net Core MVC / TypeScript
YarnSpinnerTool/YarnSpinner
Yarn Spinner is a tool for building interactive dialogue in games!
open-rpa/openrpa
Free Open Source Enterprise Grade RPA
Version Downloads Last updated
0.104.2 329,150 11/15/2024
0.104.1 1,041,206 9/30/2024
0.104.0-rc1 38,869 9/17/2024
0.104.0-preview2 323,409 10/26/2023
0.103.0-beta 28,040 9/28/2023
0.102.3 1,958,819 7/18/2024
0.102.2 7,118,778 1/5/2024
0.102.1 4,679,602 8/18/2023
0.102.0 1,842,306 6/24/2023
0.102.0-rc 6,763 6/18/2023
0.101.0 2,950,338 4/9/2023
0.101.0-rc 4,783 4/1/2023
0.100.3 3,762,212 1/12/2023
0.100.2 61,652 1/10/2023
0.100.1 27,438 1/9/2023
0.100.0 128,767 1/9/2023
0.97.0 4,395,411 10/21/2022
0.96.0 6,454,128 6/29/2022
0.95.4 22,395,014 12/16/2020
0.95.3 8,691,419 5/25/2020
0.95.2 723,262 4/26/2020
0.95.1 218,639 4/23/2020
0.95.0 1,179,218 4/15/2020
0.95.0-beta2 103,155 8/21/2019
0.95.0-beta1 44,474 4/4/2019
0.94.2 6,780,399 12/18/2018
0.94.0 70,705 12/12/2018
0.94.0-rc2 5,332 11/29/2018
0.94.0-rc1 8,553 11/11/2018
0.93.1 1,096,053 8/7/2018
0.93.0 507,989 6/25/2018
0.93.0-rc3 8,166 6/7/2018
0.93.0-rc2 4,272 5/31/2018
0.93.0-beta4 4,739 5/14/2018
0.93.0-beta2 5,410 4/26/2018
0.93.0-beta1 2,931 4/19/2018
0.92.1 1,202,294 4/10/2018
0.92.0-beta1 6,021 3/22/2018
0.91.1 62,426 4/4/2018
0.91.0 310,413 1/31/2018
0.91.0-beta3 4,286 1/23/2018
0.91.0-beta2 14,590 12/8/2017
0.91.0-beta1 2,964 11/29/2017
0.90.0 760,159 10/23/2017
0.90.0-beta2 3,268 10/6/2017
0.89.0 400,782 9/12/2017
0.89.0-beta1 5,325 8/23/2017
0.88.0 226,665 7/24/2017
0.88.0-beta1 10,560 7/10/2017
0.87.1 1,771,884 4/3/2017
0.86.0 437,518 1/6/2017
0.85.0 347,854 12/7/2016
0.80.1 746,245 9/15/2016
0.76.0 1,697,012 12/16/2014
0.75.0 214,565 9/17/2014
0.74.0 43,672 8/10/2014
0.73.0 40,162 6/24/2014
0.72.3 29,149 6/4/2014
0.72.2 4,734 6/4/2014
0.72.1 58,771 6/4/2014
0.72.0 11,579 6/4/2014
0.71.1 17,969 5/26/2014
0.70.0 13,393 5/18/2014
0.69.2 167,178 10/3/2013
0.69.1 87,516 8/15/2013
0.69.0 7,675 8/10/2013
0.68.1 107,045 10/20/2012
0.68.0 6,194 10/12/2012
0.67.2 24,197 8/14/2012
0.67.1 4,772 8/13/2012
0.67.0 4,896 8/12/2012
0.66.1 5,582 7/28/2012
0.66.0 5,156 7/18/2012
0.65.2 10,404 4/21/2012
0.64.0 24,304 2/4/2012