找回密码
 立即注册

QQ登录

只需一步,快速开始

lud
论坛元老   /  发表于:2012-2-23 18:15  /   查看:15024  /  回复:20
能不能输入数据是显示千位分隔符,并且负数也是这样

20 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2012-2-24 09:30:00
沙发

回复 1# lud 的帖子

lud 你好,
可以使用 GeneralCellType 实现该功能,测试代码:

  1.             FarPoint.Web.Spread.GeneralCellType generalCellType1 = new FarPoint.Web.Spread.GeneralCellType();
  2.             generalCellType1.NumberFormat = ((System.Globalization.NumberFormatInfo)(new System.Globalization.CultureInfo("zh-CN", false).NumberFormat.Clone()));
  3.             generalCellType1.NumberFormat.NumberGroupSeparator = ",";
  4.             generalCellType1.NumberFormat.NumberGroupSizes = new int[] { 3 };
  5.             this.FpSpread1.Sheets[0].Cells[0, 0].CellType = generalCellType1;
  6.             this.FpSpread1.Sheets[0].Cells[0, 0].Value = -55123456;
复制代码
回复 使用道具 举报
lud
论坛元老   /  发表于:2012-2-24 10:05:00
板凳
版主,你好,我按照你设置的代码,显示是没有效果
    public static FarPoint.Web.Spread.DoubleCellType DoubleType()
    {
      FarPoint.Web.Spread.DoubleCellType dblcell =     new FarPoint.Web.Spread.DoubleCellType();
      //dblcell.ErrorMessage = "-";
      dblcell.MaximumValue = 999999999999999.99;
      dblcell.MinimumValue = -999999999999999.99;
      //dblcell.NegativeRed = true;
      //dblcell.IsDateFormat = false;

        
   
      dblcell.FixedPoint = true;


      dblcell.ErrorMessage = "请输入数值型数据";


      dblcell.FixedPoint = true;
      dblcell.NumberFormat = new System.Globalization.NumberFormatInfo();
  
      dblcell.NumberFormat.NumberGroupSeparator = ",";

      dblcell.NumberFormat.NumberDecimalDigits = 2;//控制小数点位数


      return dblcell;
    }
这是我开始设置的代码,但是这样的代码只有在后台赋值显示的时候才出现千位符,在单元格里输入值则不显示,我也参考过你在另一里的输入设置,但是那样的操作负数不能输入
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-2-24 10:19:00
地板

回复 3# lud 的帖子

lud 你好,
以下使用你的设置方法进行改进:
1.前台添加 FpSpread.DataChanged 事件:
  1.     <script language="javascript" type="text/javascript" id="FpSpread1_Script0">
  2.                 function FpSpread1_DataChanged(event){
  3.                     //Add code to handle your event here.
  4.                     FpSpread1.UpdatePostbackData();
  5.                     FpSpread1.CallBack("Update");
  6.                 }
  7.         </script>
复制代码
2.后台添加 Spread UpdateCommand 事件:
  1.         protected void FpSpread1_UpdateCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
  2.         {
  3.         }
复制代码
回复 使用道具 举报
lud
论坛元老   /  发表于:2012-2-24 10:44:00
5#
好的,我试下
回复 使用道具 举报
lud
论坛元老   /  发表于:2012-2-24 11:05:00
6#
FpSpread.DataChanged 事件在哪里用呀,我在Load上用,都不能输入
回复 使用道具 举报
lud
论坛元老   /  发表于:2012-2-24 11:08:00
7#
版主可以把你做的Demo附注一下吗
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-2-24 11:40:00
8#
不好意思,我没有解释清楚:
1.前台添加 FpSpread.DataChanged 事件,Spread 前台事件,查看 Spread ClientEvent 属性。:

  1.     <script language="javascript" type="text/javascript" id="FpSpread1_Script0">
  2.                 function FpSpread1_DataChanged(event){
  3.                     //Add code to handle your event here.
  4.                     FpSpread1.UpdatePostbackData();
  5.                     FpSpread1.CallBack("Update");
  6.                 }
  7.         </script>
复制代码
2.后台添加 Spread UpdateCommand 事件:

  1.         protected void FpSpread1_UpdateCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
  2.         {

  3.         }
复制代码
3.下面是我的 Demo,请参考:
3446.zip (2.77 MB, 下载次数: 727)
回复 使用道具 举报
lud
论坛元老   /  发表于:2012-2-24 13:18:00
9#
谢谢版主,问题解决
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-2-24 13:27:00
10#

回复 9# lud 的帖子

:share:
回复 使用道具 举报
123下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部