OLEDB读取Excel十进制值 [英] OleDB Read Excel decimal value

查看:146
本文介绍了OLEDB读取Excel十进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用OLEDB王牌12读取包含十进制值的列的Excel(XSLX)表。当我打开Excel表我的电脑上一个十进制值正确格式为 1.850,50 (NLD文化以逗号作为小数点分隔)

I am using OleDB Ace 12 to read an Excel (xslx) sheet containing a column with decimal values. When I open the Excel sheet on my PC a decimal value is correctly formatted as 1.850,50 (NLD culture with comma as decimal separator)

当我读出使用OLEDB(C#4.0),该字段的字符串值始终是 1,850.50 (美制)的Excel工作表

When I'm reading out the Excel sheet using OleDB (C#4.0), the string value of this field is always 1,850.50 (US format)

我试过设置了DataSet我填的区域,设置currentthread的文化多,但DataSet中充满了OLEDB适配器总是返回美国格式化小数。

I've tried setting the Locale of the DataSet I fill, set the currentthread's culture and more, but the DataSet filled with OleDB adapter always returns US formatted decimals.

我能否更改读书时格式化值的方式吗?或者是它总是美国格式不管是什么?

Can I change the way it formats the value when reading? Or is it always US format no matter what?

推荐答案

我觉得你只会得到它美国的格式。你可以把它转换成代码:

I think you will get it US format only. You can convert it in code:

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")));

这篇关于OLEDB读取Excel十进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆