OleDB读取Excel十进制值

我使用OleDB Ace 12来读取包含带小数值的列的Excel(xslx)表。 当我在PC上打开Excel工作表时,十进制值的格式正确为1.850,50 (使用逗号作为小数分隔符的NLD文化)

当我使用OleDB(C#4.0)读出Excel表格时,该字段的字符串值始终为1,850.50 (美国格式)

我已经尝试设置我填充的DataSet的Locale,设置currentthread的文化等等,但是填充了OleDB适配器的DataSet总是返回US格式的小数。

我可以在阅读时更改格式化值的方式吗? 或者无论如何它总是美国格式?

我想你会得到美国格式。 你可以用代码转换它:

 string strFloatingNumber = "24.45"; //a floating point number in English notation double output = 0.0; //output double number which will hold the value double.TryParse(strFloatingNumber, out output); //convert without exception - assuming no error MessageBox.Show(output.ToString("N2", CultureInfo.CreateSpecificCulture("nl-NL")));