I'm having a bit of a problem reading a value from an Excel 2010 worksheet.
On a standard Excel 2010 worksheet I have a cell with the currency format with two decimal places and the value 1270,14 €.
When I read this value on OpenXML 2.0 (C# code) I get 1270.1400000000001 instead of the original 1270.14.
The same happens with other values on any cell with the same formating.
Get value from cell OpenXML code:
private string GetCellValue(string column, int row)
{
    column = column.ToUpper();
    var targetCell = cells.Where(p => p.CellReference == (column + row)).SingleOrDefault();
    var value = String.Empty;
    if (targetCell.DataType != null && targetCell.DataType.Value == CellValues.SharedString)
    {
        var index = int.Parse(targetCell.CellValue.Text);
        value = cellValues[index].InnerText.Trim();
    }
    else
    {
        if (targetCell.CellValue != null)
        {
            value = targetCell.CellValue.Text.Trim();
        }
        else
        {
            value = null;
        }
    }
    return value;
}
The specific value passes over the 'if' DataType is not null condition and retrieves the value with the line:
value = targetCell.CellValue.Text.Trim();
How can this be fixed ?
Why is this error even possible ?
 
     
    