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

Getting format exception and not getting proper value of a cell which shows properly on excel #113

Closed
YonathanFeyessa opened this issue Nov 28, 2016 · 6 comments

Comments

@YonathanFeyessa
Copy link

YonathanFeyessa commented Nov 28, 2016

I am getting a '((ClosedXML.Excel.XLCell)timeCell).Value' threw an exception of type 'System.FormatException' when trying to access the value of a cell which contains a date with a custom format of [$-en-US]dddd, mm/dd .

Appreciate all the help.

@igitur
Copy link
Member

igitur commented Nov 28, 2016

ClosedXML won't be able to evaluate a custom format like that. I suggest changing the format to something more standard before trying to retrieve the value.

@YonathanFeyessa
Copy link
Author

thanks for the reply I changed the format to a standard date format and still throwing the same error....is there another lib you suggest for this kind of issues. thank you

@igitur
Copy link
Member

igitur commented Nov 28, 2016

If you can attach your spreadsheet, I can have a look at the problem.

@YonathanFeyessa
Copy link
Author

Book1.xlsx
Can you format the cell with Monday, 11/21 text. Thank you.

@igitur
Copy link
Member

igitur commented Nov 28, 2016

Using the latest code from the develop branch, I can successfully retrieve the date value using this code:

private static void Main(string[] args)
{
    using (var wb = new XLWorkbook("test.xlsx"))
    {
        var ws = wb.Worksheets.First();
        var cell = ws.Cell("B11");
        cell.Style.NumberFormat.SetFormat("yyyy-MM-dd");
        cell.DataType = XLCellValues.DateTime;
        Console.WriteLine(cell.Value);
    }

    Console.WriteLine("Press any key to continue");
    Console.ReadKey();
}

@YonathanFeyessa
Copy link
Author

ok Thank you I will clone and test.

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