Project has been on hiatus for a while, but things are now moving forward.
See full list of changes at https://github.com/ClosedXML/ClosedXML/milestone/17?closed=1
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)
XLDataType.DateTime
or XLDataType.TimeSpan
. The DataType has to be set explicitely.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 installedUse 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 (spreadsheetlab/XLParser#163, spreadsheetlab/XLParser#161). Not-so-close future of CalcEngine is also multi threaded.
CalcEngine redesignCalcEngine 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
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}");
Future plansResult: 9
We hope to make a release every few months. For the next release, the general plan is to work on neglected things before new features.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4