0

I am using ClosedXML to read a excel file. But for some reason closed xml is rounding the cell value which is number formatted to 16th decimal. Example the value I am getting is 0.0232080359530551 instead of 0.02320803595305504993. I looked at this! article and tried it but did not work out.

Tried all these options but no success.

string me = string.Empty;
me = row.Cell(i).ValueCached;
me = row.Cell(i).RichText.ToString();
me = row.Cell(i).Value.ToString();
double d = 0.00000000000000000000;
d = row.Cell(i).GetDouble();
row.Cell(i).TryGetValue<double>(out d);
var fme = row.Cell(i).GetValue<double>().ToString("N30");
var fmesd = row.Cell(i).GetValue<float>().ToString("N30");
var dddsdsd = Convert.ToDouble(row.Cell(i).GetType().GetField("_cellValue", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(row.Cell(i)));
var sdfljdlf = row.Cell(i).GetValue<string>();
dwirony
  • 5,487
  • 3
  • 21
  • 43
Sandillio Sandy
  • 29
  • 1
  • 11
  • Excel's advertised number precision is 15 digits. I don't know of any way to get a number with 20 decimal digits in Excel, unless that value is stored in Excel as a string. – Ron Rosenfeld Apr 09 '19 at 02:22

1 Answers1

2

If your Datatype in Excel is Number, then Excel already rounds it to 15 digits. If it is Text, then you get the full length with GetValue<string>() or as number with GetValue<decimal>().

Raidri
  • 17,258
  • 9
  • 62
  • 65