I have a value in a NameValueCollection that is .22. That value is loaded into a float fValue
.
The value is fValue=0.22 in debug, when it is written into Excel.
InvoiceWs.Cells["I" + iRow.ToString()].Style.Numberformat.Format = "$#,##0.00";
fValue = float.Parse(nvcUnitPrice["LG3000"].ToString());
InvoiceWs.Cells["I" + iRow.ToString()].Value = fValue;
When I open the Excel file, I see that the value is 0.219999998807907 and I am unable to figure out what is going on. Any ideas?
Since you are working with prices you should use the decimal type. From msdn https://msdn.microsoft.com/en-us/library/364x0z75.aspx. Glad to help you