Excel complains German date format

Topics: Developer Forum
Jul 31, 2008 at 4:22 PM
Edited Aug 1, 2008 at 7:32 AM
The German date format is of the form dd.mm.yyyy
if I use the following statement
Excel complains bad XML (but is able to correct it)

imho the problem is, that in ExcelCells.cs Line 147
if (IsNumericValue(value))
with value="1.1.2008"
is true
and that may be misleading.

Wouln't it be better, if one changes the type of value to Object and do some
            switch (value.GetType().Name)
                case "String":
                case "DateTime":
                case ...
Thanks at all
Ariadne, Switzerland
Jun 7, 2013 at 9:47 AM
Edited Jun 7, 2013 at 10:06 AM
hm I had the same problem.

But I found a good solution I think.
I used the following assignment in my code
    string styleBeforeString = worksheet.Cell(4, 3).Style;
    string stylebeforeInt  =  worksheet.Cell(4, 3).StyleID;

    worksheet.Cell(4, 3).Value = container.StartDateSelection.ToOADate().ToString();

    worksheet.Cell(4, 3).Style =styleBeforeString;
    worksheet.Cell(4, 3).StyleID = stylebeforeInt;
So I assign the ole datatype value (its a double value). But seriously after an assignemnt the formattings get lost. So I reassign the formatstyles.