Row total and column total changes when cell value changes

Posted by: farmsim on 15 September 2017, 3:26 am EST

  • Posted 15 September 2017, 3:26 am EST

    How can I show Row total and column total changes when cell value changes?

    Below is the code, and attached the snapshot

    protected void Page_Load(object sender, EventArgs e)

    {

    FpSpread1.EnableAjaxCall = true;

            FpSpread1.ClientAutoCalculation = true;
    
            if (!IsPostBack)
            {
                FpSpread1.ActiveSheetView.AddColumns(19, 1);
    
                FpSpread1.Sheets[0].ColumnHeader.Cells[0, 19].Text = "Total";
    
                DateTime dt = Convert.ToDateTime("01/27/2017");
    
                for (int i = 5; i <= 18; i++)
                {
                    FpSpread1.Sheets[0].ColumnHeader.Cells[0, i].Text = dt.AddDays(i - 18).ToString("ddd") + " " + dt.AddDays(i - 18).ToString("MM/dd");
                }
    
                for (int i = 5; i <= 19; i++)
                {
                    FpSpread1.Sheets[0].Columns[i].Width = 56;
                }
    
                FpSpread1.Sheets[0].ColumnFooter.Cells[0, 4].Value = "Total: ";
    
                int RowCount = Convert.ToInt32(this.FpSpread1.ActiveSheetView.RowCount);
    
                FpSpread1.ActiveSheetView.ColumnCount = 20;
    
                // Set formula.
                FpSpread1.Sheets[0].ReferenceStyle = FarPoint.Web.Spread.Model.ReferenceStyle.R1C1;
                FpSpread1.Sheets[0].Columns[19].Formula = "SUM(RC5:RC18)";
                FpSpread1.Sheets[0].Columns[19].HorizontalAlign = HorizontalAlign.Right;
    
    
                FarPoint.Web.Spread.DateTimeCellType dt2 = new FarPoint.Web.Spread.DateTimeCellType();
                System.Globalization.DateTimeFormatInfo dtf = new System.Globalization.DateTimeFormatInfo();
                dtf.LongDatePattern = "D";
                dtf.ShortDatePattern = "M/d/yyyy";
                dt2.DateTimeFormat = dtf;
                FpSpread2.Sheets[0].Cells[0, 0, 0, 2].CellType = dt2;
                FpSpread2.ActiveSheetView.Cells[0, 0].Value = DateTime.Now;
    
                FarPoint.Web.Spread.FilterBarCellType fbcell = new FarPoint.Web.Spread.FilterBarCellType(true);
                fbcell.DatePickerMode = FarPoint.Web.Spread.DatePickerMode.Auto;
    
                FpSpread2.Sheets[0].RowCount = 6;
                FpSpread2.Sheets[0].ColumnCount = 6;
                //Customize "Cells" in Filter Bar
                FarPoint.Web.Spread.SheetView sheetView = FpSpread2.ActiveSheetView;
                sheetView.AutoFilterMode = FarPoint.Web.Spread.AutoFilterMode.FilterBar;
                sheetView.FilterBar.Cells[0].CellType = fbcell;
                sheetView.FilterBar.Cells[0].BackColor = System.Drawing.Color.Aqua;
    
            }
    
        }
    
      
        protected void FpSpread1_CellClick(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
        {
            int RowCount = Convert.ToInt32(this.FpSpread1.ActiveSheetView.RowCount);
    
            FpSpread1.ActiveSheetView.ColumnCount = 20;
    
            // Set formula.
            FpSpread1.Sheets[0].ReferenceStyle = FarPoint.Web.Spread.Model.ReferenceStyle.R1C1;
            FpSpread1.Sheets[0].Columns[19].Formula = "SUM(RC5:RC18)";
            FpSpread1.Sheets[0].Columns[19].HorizontalAlign = HorizontalAlign.Right;
        }
    

  • Posted 15 September 2017, 3:26 am EST

    Hello,

    Sum in the ColumnFooter will not update client side, it requires a postback to calculate the sum of column and show it in the ColumnFooter.

    However you can handle the OnEditStopped event client and update the edited value which will ultimately result in the updated sum in column footer.

    Please have a look at the attached sample application to see the implementation.

    Thanks,

    Deepak Sharma

    2017/07/SpreadWebTotal.zip

  • Posted 4 March 2019, 4:53 pm EST

    Hello.

    i want to do that but with SpreadSheet JS. i read the documentation but “ColumnFooter” doen’t work.

    Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels