Hello,
When i try to open a excel file which contains a cell containing an invalid date, Excel displays it with ####### into the cell and 3778816,1688361 into the edit bar. But when I try to open the file with EPPlus, it raises an exception invalid OleAut date.
You will find an excel invalid file as attachments, and the following code can correct the issue. (it modifies the ExcelWorksheet class)
You can chekced that here : [http://msdn.microsoft.com/fr-fr/library/system.datetime.fromoadate.aspx](http://msdn.microsoft.com/fr-fr/library/system.datetime.fromoadate.aspx)
```
private object GetValueFromXml(ExcelCell cell, XmlTextReader xr)
{
object value;
//XmlNode vnode = colNode.SelectSingleNode("d:v", NameSpaceManager);
//if (vnode == null) return null;
if (cell.DataType == "s")
{
int ix = xr.ReadElementContentAsInt();
value = _package.Workbook._sharedStringsList[ix].Text;
cell.IsRichText = _package.Workbook._sharedStringsList[ix].isRichText;
}
else if (cell.DataType == "str")
{
value = xr.ReadElementContentAsString();
}
else if (cell.DataType == "b")
{
value = (xr.ReadElementContentAsString() != "0");
}
else
{
int n = cell.Style.Numberformat.NumFmtID;
string v = xr.ReadElementContentAsString();
if ((n >= 14 && n <= 22) || (n >= 45 && n <= 47))
{
double res;
if (double.TryParse(v, NumberStyles.Any, CultureInfo.InvariantCulture, out res))
{
if (res >= -657435.0 && res < 2958465)
value = DateTime.FromOADate(res);
else
value = "";
}
else
{
value = "";
}
}
else
{
double d;
if (double.TryParse(v, NumberStyles.Any, CultureInfo.InvariantCulture, out d))
{
value = d;
}
else
{
value = double.NaN;
}
}
}
return value;
}
```
Regards, and thanks for this excellent component !
Comments: No way to get any worksheet if there's an invalid date on any cell, since getting package.Workbook.Worksheets will throw the exception. Would be a nice fix!