Excel未使用默认编号组分隔符正确格式化数字 [英] Excel not formatting numbers properly with default number group separator

查看:97
本文介绍了Excel未使用默认编号组分隔符正确格式化数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我是小型企业的开发人员。我遇到了一个客户遇到此问题。


当计算机具有区域设置"荷兰语(比利时)"时 - "nl-BE" (或"Nederlands(België)"), 默认的数字组分隔符看起来像一个空格。当数字通过我们的Windows
应用程序导出到excel文件时,它将数字格式化为字符串。不是数字..


事实证明,默认的数字组分隔符不是空格,而是由ASCII字符194 160组成.Excel似乎无法将文本解析为数字那些ASCII字符作为分隔符。 ASCII字符出现在
输出文件中。但这些数字被解释为文本。


当我将区域设置更改为其他设置但将默认数字组分隔符修改为相同的ASCII字符194 160时,Excel无法解释数字就是这样。


应用程序遵循的路径简而言之:


1。数字在数据网格视图中。


2。选择所有记录并将其复制到剪贴板。


3。生成一个新的Excel文件,其中包含一个粘贴数据的工作表。


在我们的开发站上,我们可以通过更改实际空格中的默认数字组分隔符来解决问题。但是对于这个客户端,我们不允许进行更改。


我的计算机在安装了所有最新更新的Windows 8 EE上运行。该应用程序是在.net framework 4.5中的Visual Studio 2012中开发的,其中Office 2013适用于家庭和小型企业。



祝你好运,


Jan Vermeer

解决方案

你好Jan,


根据描述,您正在开发一个应用程序导入数据到Excel工作表中。它将数字格式化为字符串。


您是否介意共享一些有关如何导入数据的代码段?


就我测试而言,当我将数据从一个工作表复制到另一个工作表时,数据正确地复制为数字。以下是代码:

 Sheet2.Range(" A1:A3")。复制
Sheet3.Paste

我怀疑当数据复制到剪贴板时可能存在不一致。作为一种解决方法,我们循环数据并逐个单元地设置值。


希望它有用。


问候&费


Hi all,

I'm a developer for a small business. I'm experiencing this problem with one of our clients.

When the computer has the regional settings "Dutch (Belgium)" - "nl-BE" (or "Nederlands (België)"),  the default number group separator looks like a whitespace. When numbers are exported to an excel file via our Windows application, it formats the numbers as strings. Not as numbers..

It turns out that the default number group separator is not a whitespace but consists of the ASCII characters 194 160. Excel seems to be unable to parse the text as numbers with those ASCII characters as separator. The ASCII characters are present in the outputfile. But the numbers are interpreted as text.

When I change my regional settings to another setting but modify the default number group separator into the same ASCII characters 194 160, Excel can't interpret the numbers as such either.

The path the application follows is in short this:

1. Numbers are in a datagridview.

2. All records are selected and copied to the clipboard.

3. A new excel file is generated with one worksheet in which the data is pasted.

On our development stations we have been able to workaround the problem by changing the default number group separator in an actual whitespace. But with this client we're not allowed to make that change.

My computer runs on Windows 8 EE with all the latest updates installed. The application is developed in Visual Studio 2012 in .net framework 4.5 with Office 2013 for home use and small businesses.

Best regards,

Jan Vermeer

解决方案

Hi Jan,

According the description, you were developing an applicaiton import data into Excel worksheets. And it formats the number as strings.

Would you mind sharing some code snippet about how you import the data?

And as far as I tested, when I copy the data from one worksheet to another, the data copy as numbers correctly. Here is the code:

Sheet2.Range("A1:A3").Copy
Sheet3.Paste

I suspect there maybe incoorect when the data copy into clipboard. As a workaround, we loop the data and set the value cell by cell.

Hope it is helpful.

Regards & Fei


这篇关于Excel未使用默认编号组分隔符正确格式化数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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