I have a column in excel where numbers are rounded to 2 decimal places using ROUNDUP.
In excel itself the numbers look as they should after rounding, i. e. "2,22".
But when I read the numbers in c# code using openxml, instead of 2,22 I get "2,2199999999999998".
So it looks like ROUNDUP does not really change numbers, just the way they are displayed.
How can I round a number in such a way that it can be read by openxml exactly as it is shown in excel?
The excel sheet looks like this:
And the code like this:
using (var excelPackage = new ExcelPackage(File.OpenRead(pathToFile))) {
var worksheet = excelPackage.Workbook.Worksheets.FirstOrDefault();
var value = worksheet.Cells[2, 2].GetValue<string>();// "2,2199999999999998"
}