Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetDouble throws exception for empty cell instead of default value #1177

Open
1 of 3 tasks
GrupoSondar opened this issue Apr 8, 2019 · 1 comment
Open
1 of 3 tasks

Comments

@GrupoSondar
Copy link

Do you want to request a feature or report a bug?

  • Bug
  • Feature

Version of ClosedXML

0.94.2

What is the current behavior?

When calling XLCell.GetDouble() on a empty cell a exception is thrown

What is the expected behavior or new feature?

GetDouble() should return type default (0.0D in this case)

Did this work in previous versions of our tool? Which versions?

Haven't used previous versions

Code to reproduce problem:

public void Main()
{
            var filepath = "PATH_TO_FILE";
            var sheetname = "SHEET_NAME";

            var workBook = new XLWorkbook(filepath, XLEventTracking.Disabled);
            var workSheet = workBook.Worksheet(sheetname);
            var row = workSheet.Row(1);
            var value = row.Cell("A").GetDouble(); //Exception thrown here
}
  • I attached a sample spreadsheet. (You can drag files on to this issue)
@igitur
Copy link
Member

igitur commented Apr 9, 2019

This is by design. We deliberately want to return a Double value only if the cell contents is of Double type. You should check the cell.DataType or cell.IsEmpty() in order to determine whether you can use cell.GetDouble().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants