paulyoder / LinqToExcel

Use LINQ to retrieve data from spreadsheets and csv files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Input string was not in a correct format" reading float number 0,00001

olivercortinas opened this issue · comments

Hi,
I'm getting the error "" when is reading from a column the value "0,00001", this column is read as a string, but when the value change to "1,00001" this is working.
Any clue why?

the code basicaly ius this:

var sheetName = Properties.Resources.SHEET_NAME;
var instrumentsColNameDefaultValue = Properties.Resources.DEFAULTVALUE_COL;
var excel = new ExcelQueryFactory();
excel.FileName = path;
excel.ReadOnly = true;

excel.AddMapping<DataSheet>(x => x.DefaultValue, instrumentsColNameDefaultValue);

var lista = (from c in excel.Worksheet<DataSheet>(sheetName) select c).ToList();

and this ToList() throw the error if the text is "0,00001" but not when "1,00001"

This is probably caused by the computer's locale. In North America, decimal numbers use dots, and not commas. If the computer in this case was configured with a North American locale, then it would not be able to read 0,00001 because it would expect such a number to be 0.00001.