找回密码
 立即注册

QQ登录

只需一步,快速开始

qinyu1021

新手上路

1

主题

2

帖子

27

积分

新手上路

积分
27
  • 25

    金币

  • 主题

  • 帖子

最新发帖
qinyu1021
新手上路   /  发表于:2013-11-4 13:05  /   查看:5009  /  回复:3
表格计算时精度怎么设为类似Excel中“显示精度”

3 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-11-4 15:40:00
沙发
回复 1楼qinyu1021的帖子

qinyu1021 你好,
小数点计算精度可以通过 NumberCellType 的 DecimalPlaces  属性来设置,把公式所在单元格设置为 NumberCellType  即可控制小数位。

  1. FarPoint.Win.Spread.CellType.NumberCellType num = new FarPoint.Win.Spread.CellType.NumberCellType();
  2. num.DecimalPlaces = 3;
  3. num.DecimalSeparator = ",";
  4. num.FixedPoint = true;
  5. num.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.UseRegional;
  6. num.MaximumValue = 50000.0;
  7. num.MinimumValue = -1000.0;
  8. num.NegativeFormat = FarPoint.Win.Spread.CellType.NegativeFormat.Parentheses;
  9. num.NegativeRed = true;
  10. num.Separator = "/";
  11. num.ShowSeparator = true;
  12. num.SpinButton = true;
  13. num.SpinDecimalIncrement = 10;
  14. num.SpinIntegerIncrement = 5;
  15. num.SpinWrap = true;
  16. fpSpread1.ActiveSheet.Cells[0, 0].CellType = num;
  17. fpSpread1.ActiveSheet.Cells[0, 0].Value = -443.0908;
复制代码
回复 使用道具 举报
qinyu1021
新手上路   /  发表于:2013-11-5 11:10:00
板凳
回复 2楼iceman的帖子

表格的精度是可以通过DecimalPlaces属性设置,设置完了之后,其他表格引用该表格进行计算时,如何按照之前设置的精度计算?

譬如: A1=36.33,A2=30   A1通过DecimalPlaces属性设置为0,则A1显示36。
此时B1=A1/A2,我想要的结果是1.2,而不是1.211.如何实现
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-11-5 11:34:00
地板
回复 3楼qinyu1021的帖子

这种情况,在 Spread 中需要设置 B1 单元格为 NumberCellType ,并且设置 DecimalPlaces  为2.
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部