Spread for ASP.NET 9.0 Product Documentation
Using a Client Scripting Method

Many built-in capabilities are provided in the Spread HTML component (HTC) file, fpspread.htc. The fpspread.htc file implements the client-side functions for the Spread component. It provides a number of properties, methods, and events that can be used in your client-side scripting code in HTML. For a complete list of the contents, refer to the Scripting Members.

Besides using the scripting members, you can also create your own HTC file to implement client-side scripting. Refer to Developing a Custom HTC File.

The following sample code for the ASPX page uses the built-in GetValue method to total the values in the cells (all except the last cell) of the first column and uses the SetValue method to put the result in the last cell of that column. Type a value in a cell and change cells to use the onDataChanged event and see the calculation.

C#
Copy Code
protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack) return;
            FpSpread1.Sheets[0].Cells[0, 0].Value = 4;
            FpSpread1.Sheets[0].Cells[1, 0].Value = 3;
            FpSpread1.Attributes.Add("onDataChanged", "doCalc(event)");
        }
VB
Copy Code
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If (IsPostBack) Then
            Return
        End If
        FpSpread1.Sheets(0).Cells(0, 0).Value = 4
        FpSpread1.Sheets(0).Cells(1, 0).Value = 3
        FpSpread1.Attributes.Add("onDataChanged", "doCalc(event)")
    End Sub
JavaScript
Copy Code
<SCRIPT language=javascript>
  function doCalc() {
    var rc = FpSpread1.GetRowCount();
    var total = 0;
    for (var i=0; i<rc-1, i++) {
      var value = parseFloat(FpSpread1.GetValue( i, 0 ));
      total += value;
    }
    if (!isNaN(total))
      FpSpread1.SetValue(rc-1, 0, total, true);
  }
</SCRIPT>
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback