找回密码
 立即注册

QQ登录

只需一步,快速开始

iceman

社区贡献组

270

主题

1万

帖子

1万

积分

社区贡献组

积分
19311

活字格认证微信认证勋章元老葡萄

iceman
社区贡献组   /  发表于:2012-9-3 19:40  /   查看:4923  /  回复:0
鉴于论坛中有很多用户提出如何在后台拼接公式,下面给出实现方法:
  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.             if (IsPostBack)
  4.             {
  5.                 return;
  6.             }
  7.             FpSpread1.Sheets[0].ReferenceStyle = FarPoint.Web.Spread.Model.ReferenceStyle.R1C1;
  8.             this.FpSpread1.ClientAutoCalculation = true;

  9.             this.FpSpread1.Sheets[0].Cells[0, 2].Tag = "单价";
  10.             this.FpSpread1.Sheets[0].Cells[1, 3].Tag = "数量";
  11.             this.FpSpread1.Sheets[0].Cells[2, 3].Tag = "总金额";

  12.             FarPoint.Web.Spread.Cell _unitPrice = this.FpSpread1.Sheets[0].GetCellFromTag(this.FpSpread1.Sheets[0].Cells[0, 0], "单价");
  13.             FarPoint.Web.Spread.Cell _quantity = this.FpSpread1.Sheets[0].GetCellFromTag(this.FpSpread1.Sheets[0].Cells[0, 0], "数量");
  14.             FarPoint.Web.Spread.Cell _toalPrice = this.FpSpread1.Sheets[0].GetCellFromTag(this.FpSpread1.Sheets[0].Cells[0, 0], "总金额");
  15.             this.FpSpread1.Sheets[0].AllowUserFormulas = true;
  16.             string formula = "PRODUCT(" + "R" + (_unitPrice.Row.Index + 1).ToString() + "C" + (_unitPrice.Column.Index + 1).ToString() + "," + "R" + (_quantity.Row.Index + 1).ToString() + "C" + (_quantity.Column.Index + 1).ToString() + ")";

  17.             _toalPrice.Formula = formula;
  18.         }
复制代码

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部