找回密码
 立即注册

QQ登录

只需一步,快速开始

study1990
金牌服务用户   /  发表于:2012-9-29 09:30:00
11#
回复 10楼iceman的帖子

这种方法有不少缺陷,对数字不敏感,计算有误差,不如CurrencyCellType功能齐全。
还用以前的方法,设置的CurrencyCellType属性后,在火狐下是没问题的,在IE下,设置两位小数,输入两位小数后,仍然会提示错误:

1.jpg (5.86 KB, 下载次数: 43)
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-9-29 11:10:00
12#
回复 11楼study1990的帖子

study1990 你好,

提供两篇资源文章,是通过自定义单元格类型实现数据校验的,如果需求比较复杂可以参考下:
1.http://gcdn.grapecity.com/showtopic-5001.html
2.http://gcdn.grapecity.com/showtopic-2563.html

能否把你的设置代码片段贴上来看看?
回复 使用道具 举报
study1990
金牌服务用户   /  发表于:2012-9-29 14:01:00
13#
回复 12楼iceman的帖子
  1. FarPoint.Web.Spread.CurrencyCellType cc = new FarPoint.Web.Spread.CurrencyCellType("货币样式:123.45");
  2. System.Globalization.CultureInfo cl = new System.Globalization.CultureInfo("");
  3. cl.NumberFormat.CurrencySymbol = "";
  4. cl.NumberFormat.CurrencyNegativePattern = 1;//允许货币值显示为负值;
  5. cl.NumberFormat.CurrencyPositivePattern = 1;//正值正常显示;
  6. cl.NumberFormat.CurrencyGroupSeparator = ",";
  7. cl.NumberFormat.CurrencyDecimalSeparator = ".";
  8. cl.NumberFormat.CurrencyDecimalDigits =2;
  9. cc.NumberFormat = cl.NumberFormat;
  10. FpSpread1.ActiveSheetView.Cells[0, 0].CellType = cc;
复制代码

设置完类型后,在火狐下可以正常输入,为什么在IE下,输入完,就会提示错误(货币样式:123.45)呢?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-9-29 15:43:00
14#
回复 13楼study1990的帖子

你好,
1.请参考我的 Demo 看是否能满足你的需求:
6022-currencycelltype.zip (20.83 KB, 下载次数: 244)
回复 使用道具 举报
study1990
金牌服务用户   /  发表于:2012-9-29 16:44:00
15#
回复 14楼iceman的帖子

这两种方法和我写的效果在IE下一样,都是在输入132.4562后提示错误。现在需求是:输入小数位数和设定的不同时,自动修复为设定位数。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-9-29 17:48:00
16#
回复 15楼study1990的帖子

不好意思,这个 Case 无法实现。
回复 使用道具 举报
study1990
金牌服务用户   /  发表于:2012-10-10 10:16:00
17#
回复 16楼iceman的帖子

当CurrencyGroupSeparator设置为""(空字符)时,就会提示错误
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-10-10 13:44:00
18#
回复 17楼study1990的帖子

能否提供你的设置代码?请问使用以下代码还会出现问题吗?

  1. FarPoint.Web.Spread.CurrencyCellType c = new FarPoint.Web.Spread.CurrencyCellType();
  2.             System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
  3.             
  4.             nfi.CurrencyDecimalDigits = 2;
  5.             nfi.CurrencyDecimalSeparator = ".";
  6.             nfi.CurrencyGroupSeparator = "@";

  7.             c.NumberFormat = nfi;
  8.             FpSpread1.ActiveSheetView.Cells[0, 0].CellType = c;
  9.             FpSpread1.ActiveSheetView.Cells[0, 0].Value = 234.56;
复制代码
回复 使用道具 举报
study1990
金牌服务用户   /  发表于:2012-10-10 14:18:00
19#
回复 18楼iceman的帖子

这些代码不会出现问题,就是设置成空字符后出错
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-10-10 16:03:00
20#
回复 19楼study1990的帖子

问题我这边重现了。
我想可以通过自定义单元格类型实现。请参考我的 Demo:
如果格式要求比较复杂,都可以采用自定义的方式,前台校验数据都是通过 JS 正则校验的,我们可以随意编写规则。
6022-GroupSeparator.zip (25.78 KB, 下载次数: 248)
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部