回复 6楼raygy的帖子
你好,
当前列脚无法添加自定义公式,不过可以通过Spread计算引擎计算后赋值给列角即可。请参考代码:
- private bool updateFooter = false;
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- updateFooter = (bool)Session["updateFooter"];
- if( updateFooter )
- UpdateFooter();
- return;
- }
- this.FpSpread1.Sheets[0].ColumnFooter.Visible = true;
- Session["updateFooter"] = false;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- Session["updateFooter"] = true;
- UpdateFooter();
- }
- private void UpdateFooter()
- {
- FarPoint.Web.Spread.Model.DefaultSheetDataModel dataModel = FpSpread1.ActiveSheetView.DataModel as FarPoint.Web.Spread.Model.DefaultSheetDataModel;
- if (dataModel != null)
- {
- FpSpread1.SaveChanges();
- FpSpread1.ActiveSheetView.ReferenceStyle = FarPoint.Web.Spread.Model.ReferenceStyle.R1C1;
- FpSpread1.ActiveSheetView.ColumnFooter.Cells[0, 0].Value = dataModel.EvaluateExpression(0, 0, dataModel.ParseFormula(0, 0, "SUM(R1C1:R2C2)"));
- }
- }
复制代码 |