找回密码
 立即注册

QQ登录

只需一步,快速开始

jingyuking

注册会员

14

主题

42

帖子

136

积分

注册会员

积分
136

活字格认证

jingyuking
注册会员   /  发表于:2014-8-8 11:18  /   查看:5614  /  回复:5
TextCellType txt = new TextCellType();
                txt.ShowEditor = true;
                txt.AllowWrap = false;
                FpSpread1.ActiveSheetView.Cells[0, 0].CellType = txt;
                FpSpread1.ActiveSheetView.Cells[0, 1].CellType = txt;
                FpSpread1.ActiveSheetView.Cells[0, 2].CellType = txt;

                FpSpread1.ClientAutoCalculation = true;
                FpSpread1.ActiveSheetView.SetFormula(0, 2, "round(A1-B1,2)");

A1=2
B1=1
C1可以显示为1.00吗?

5 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-8-8 18:03:00
沙发
回复 1楼jingyuking的帖子

可以把Cell[0,2]设置为DoubleCellType:

  1.             FarPoint.Web.Spread.DoubleCellType db = new FarPoint.Web.Spread.DoubleCellType();
  2.             db.DecimalDigits = 2;
  3.             this.FpSpread1.ActiveSheetView.Cells[0, 2].CellType = db;
复制代码
回复 使用道具 举报
jingyuking
注册会员   /  发表于:2014-8-11 09:46:00
板凳
2.00-1.00显示的还是1呢,不能显示为1.00啊
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-8-11 18:00:00
地板
回复 3楼jingyuking的帖子

详细代码:

  1.         protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }

  7.             FarPoint.Web.Spread.DoubleCellType dblc = new FarPoint.Web.Spread.DoubleCellType();
  8.             dblc.DecimalDigits = 2;
  9.             dblc.FixedPoint = true;
  10.             FpSpread1.ActiveSheetView.Cells[0, 0].CellType = dblc;


  11.             FpSpread1.ClientAutoCalculation = true;
  12.             FpSpread1.ActiveSheetView.SetFormula(0, 2, "Round(A1-B1,2)");
  13.             this.FpSpread1.ActiveSheetView.Cells[0, 2].CellType = dblc;
  14.         }
复制代码


效果图:

Demo2.gif
回复 使用道具 举报
jingyuking
注册会员   /  发表于:2014-8-13 17:50:00
5#
之前是没有写这个,所以不起作用
dblc.FixedPoint = true;
谢谢了!:strong:
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-8-14 12:04:00
6#
回复 5楼jingyuking的帖子

很高兴能够帮助到你。

为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢

评分

参与人数 1满意度 +5 收起 理由
jingyuking + 5 谢谢,问题解决

查看全部评分

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