TimeSpan handling

Sep 8, 2014 at 2:23 PM
Is there a reason why TimeSpan data types are handled wiered when values contains value over 24 hours. Even if TimeSpan data type is set for cell the value will be reformatted by Excel when opened.
In following example produced excel file shows other values than those set in code.
        var wb = new XLWorkbook();
        var ws = wb.Worksheets.Add("TimeSpan test");

        ws.Cell(1, 2).Value = "23:00:00";   // This is good
        ws.Cell(2, 2).Value = "25:00:00";   // Not good
        ws.Cell(3, 2).Value = "35:00:00";   // Not good -> Excel reformats this
        ws.Cell(3, 2).DataType = XLCellValues.TimeSpan; // even data type is set  
        ws.Cell(4, 2).Value = new TimeSpan(35, 0, 0); // This is good
        ws.Cell(5, 2).Value = new TimeSpan(35, 0, 0).ToString(); // This is good
And resulting excel contains following:
23:00:00
600:00:00
840:00:00
35:00:00
35:00:00

Is this something expected?
Thank you.
Coordinator
Sep 8, 2014 at 7:18 PM
It's the way .NET interprets timespan strings:
        TimeSpan ts;
        TimeSpan.TryParse("25:00:00", out ts);
        Console.WriteLine(ts.TotalHours); // 600 hours = 25 days = 25.00:00:00