您好,GeneralCellType 没有那些属性,如果希望GcTextBoxCellType可以对数字进行公示可以做如下操作。 已经不能编辑公式的问题也可以在EditModeOn时解决。
- this.fpSpread1.EditModeOn += FpSpread1_EditModeOn;
- this.fpSpread1.EditModeOff += FpSpread1_EditModeOff;
-
- private void FpSpread1_EditModeOn(object sender, EventArgs e)
- {
- var activeCell = fpSpread1.ActiveSheet.ActiveCell;
- if (activeCell.CellType is GcTextBoxCellType)
- {
- var formula = activeCell.Formula;
- if (!string.IsNullOrEmpty(formula))
- {
- activeCell.Value = "=" + formula;
- }
- }
- }
- private void FpSpread1_EditModeOff(object sender, EventArgs e)
- {
- var activeCell = fpSpread1.ActiveSheet.ActiveCell;
- if (activeCell.CellType is GcTextBoxCellType && activeCell.Value != null)
- {
- string value = activeCell.Value.ToString();
- if (value.StartsWith("="))
- {
- activeCell.Formula = value.Substring(1);
- }
- else
- {
- decimal dec = 0;
- if (decimal.TryParse(value, out dec))
- {
- activeCell.Value = dec;
- }
- }
- }
- }
复制代码 |