你好,可以在给 Cell 设置公式之前设定好 formula,需要通过该列的 label 属性实现,下面是我的实现方法:
- int rowCount = this.FpSpread1.Sheets[0].RowCount;
- int columnCount = this.FpSpread1.Sheets[0].ColumnCount;
- for (int i = 0; i < columnCount; i++)
- {
- string columnLabel = this.FpSpread1.Sheets[0].ColumnHeader.Columns[i].Label;
- string formula = "SUM(" + columnLabel + "1" + ":" + columnLabel + (rowCount-1).ToString() + ")";
- this.FpSpread1.Sheets[0].Cells[rowCount-1, i].Formula = formula;
- }
复制代码 效果图:
png
|