You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not randomly delete sections. They are here for a reason.
Do you want to request a feature or report a bug?
Bug
Feature
Question
Did you test against the latest CI build?
Yes
No
Version of ClosedXML
0.104.0-preview3
What is the current behavior?
If the cell is blank date functions throw System.InvalidCastException with the message "Null object cannot be converted to a value type."
If the cell is an empty string date functions throw System.FormatException with the message "String '' was not recognized as a valid DateTime."
What is the expected behavior or new feature?
If the cell is blank date functions return the same value as if the cell had zero value.
If the cell is an empty string date functions return an "error" value.
Is this a regression from the previous version?
No, it's not. I also checked version 0.102.2.
Reproducibility
I wrote two tests.
Code to reproduce problem:
[TestCase(31,"EOMONTH(A1,0)")]//System.InvalidCastException : Null object cannot be converted to a value type.[TestCase(5,"A1+5")]//PassedpublicvoidDateFormula_ReturnCorrectValue_WhenCellIsBlank(intexpectedValue,stringformula){using(varwb=new XLWorkbook()){
wb.ReferenceStyle = XLReferenceStyle.A1;varws= wb.AddWorksheet("Sheet1");
Assert.AreEqual(expectedValue, ws.Evaluate(formula).GetNumber());}}[TestCase("EOMONTH(A1,0)")]//System.FormatException : String '' was not recognized as a valid DateTime.[TestCase("A1+1")]//PassedpublicvoidDateFormula_ReturnError_WhenCellIsEmpty(stringformula){using(varwb=new XLWorkbook()){
wb.ReferenceStyle = XLReferenceStyle.A1;varws= wb.AddWorksheet("Sheet1");
ws.Cell("A1").SetValue("");
Assert.IsTrue(ws.Evaluate(formula).IsError);}}
I attached a sample spreadsheet. (You can drag files on to this issue)
In the file wb.xlsx cell A1 contains the formula for a blank cell, cell B1 contains the formula for an empty string.
The text was updated successfully, but these errors were encountered:
Read and complete the full issue template
Do not randomly delete sections. They are here for a reason.
Do you want to request a feature or report a bug?
Did you test against the latest CI build?
Version of ClosedXML
0.104.0-preview3
What is the current behavior?
If the cell is blank date functions throw
System.InvalidCastException
with the message "Null object cannot be converted to a value type."If the cell is an empty string date functions throw
System.FormatException
with the message "String '' was not recognized as a valid DateTime."What is the expected behavior or new feature?
If the cell is blank date functions return the same value as if the cell had zero value.
If the cell is an empty string date functions return an "error" value.
Is this a regression from the previous version?
No, it's not. I also checked version 0.102.2.
Reproducibility
I wrote two tests.
Code to reproduce problem:
In the file wb.xlsx cell A1 contains the formula for a blank cell, cell B1 contains the formula for an empty string.
The text was updated successfully, but these errors were encountered: