请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

sliang79

高级会员

26

主题

66

帖子

1764

积分

高级会员

积分
1764

活字格认证

sliang79
高级会员   /  发表于:2011-10-30 17:03  /   查看:5211  /  回复:2
查了帮助文件发现公式里是"SUM(A1:A3)",我的控件最后一行为求和,最后一行每一个单元格对这一列求和,上面的行数未定,只能用RowCount,另外列数比较多有几十列,可以用循环来完成吗

2 个回复

正序浏览
wp_pandy
高级会员   /  发表于:2011-11-3 22:14:00
板凳
哈哈,那这个方法也可以做合计行了!,哈哈我试试
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2011-10-31 11:51:00
沙发
你好,可以在给 Cell 设置公式之前设定好 formula,需要通过该列的 label 属性实现,下面是我的实现方法:

  1. int rowCount = this.FpSpread1.Sheets[0].RowCount;
  2. int columnCount = this.FpSpread1.Sheets[0].ColumnCount;

  3. for (int i = 0; i < columnCount; i++)
  4. {
  5.                 string columnLabel = this.FpSpread1.Sheets[0].ColumnHeader.Columns[i].Label;
  6.                 string formula = "SUM(" + columnLabel + "1" + ":" + columnLabel + (rowCount-1).ToString() + ")";
  7.                 this.FpSpread1.Sheets[0].Cells[rowCount-1, i].Formula = formula;
  8.             }
复制代码
效果图:

png

png
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部