请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

HNA_fengjie

论坛元老

39

主题

97

帖子

1万

积分

论坛元老

积分
14189

活字格认证

HNA_fengjie
论坛元老   /  发表于:2011-11-10 18:42  /   查看:4960  /  回复:1
你好,我把单元格类型已经设置如下:
DoubleCellType dct = new DoubleCellType(-99999999999999.00D, 99999999999999.00D, "请输入规范数据!(例:12.34)");
                dct.NumberFormat = new System.Globalization.NumberFormatInfo();
                dct.DecimalDigits = 2;
                dct.FixedPoint = true;
                sheetView.Cells[iRowIndex, iColumnIndex].CellType = dct;

                if (!string.IsNullOrEmpty(cellText))
                {
                    sheetView.Cells[iRowIndex, iColumnIndex].Text = cellText;
                }
当cellText赋值为7199999928.00时出现异常“值对于 Int32 太大或太小”!
请协助设置一下,谢谢~~~~

1 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2011-11-11 09:53:00
沙发
你好,

你的代码中有几行我不是十分明白应该如何使用,是在循环中使用吗,能否给一个详细一些的代码,谢谢。

  1.                //不清楚以下代码该如何使用
  2.                sheetView.Cells[iRowIndex, iColumnIndex].CellType = dct;

  3.                 if (!string.IsNullOrEmpty(cellText))
  4.                 {
  5.                     sheetView.Cells[iRowIndex, iColumnIndex].Text = cellText;
  6.                 }
复制代码
我将以上代码修改之后没有出现错误提示:
  1.             DoubleCellType dct = new DoubleCellType(-99999999999999.00D, 99999999999999.00D, "请输入规范数据!(例:12.34)");
  2.             dct.NumberFormat = new System.Globalization.NumberFormatInfo();
  3.             dct.DecimalDigits = 2;
  4.             dct.FixedPoint = true;
  5.             FpSpread1.ActiveSheetView.Cells[0,0].CellType = dct;
复制代码
运行结果:
1.png (15.31 KB, 下载次数: 81)
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部