如果只是要显示效果的话,可以通过自定义单元格类型来实现(替代单元格格式设置)
自定义单元格类型
- private class RoundValueCellType : FarPoint.Win.Spread.CellType.GeneralCellType
- {
- public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
- {
- if (value != null&&value.GetType()==typeof(Double))
- {
-
- value = Math.Round((double)value, 2).ToString();
- }
-
- base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
- }
- }
复制代码
使用自定义的单元格
- fpSpread1.ActiveSheet.Cells[3, 3].CellType = new RoundValueCellType() ;
- fpSpread1.ActiveSheet.Cells[3, 3].Value= 9.825;
复制代码
|