Spread for ASP.NET 12 Product Documentation
Setting the Cell Types of the Register
Spread for ASP.NET 12 Product Documentation > Developer's Guide > Getting Started > Tutorial: Creating a Checkbook Register > Setting the Cell Types of the Register

To set cell types, for each custom cell type, you have to create a cell type object, set the properties for it, and then assign that object to the CellType property for a cell or range of cells.

  1. Set the cell type for the Check # column by adding the following code below the code you have already added:
    C#
    Copy Code
    // Create Check # column of integer cells.
    FarPoint.Web.Spread.IntegerCellType objIntCell = new FarPoint.Web.Spread.IntegerCellType();
    FpSpread1.Sheets[0].Columns[0].CellType = objIntCell;
    
    VB
    Copy Code
    ' Create Check # column of integer cells.
    Dim objIntCell As New FarPoint.Web.Spread.IntegerCellType()
    FpSpread1.Sheets(0).Columns(0).CellType = objIntCell
    
  2. Set the cell type for the Date column by adding the following code below the code you have already added:
    C#
    Copy Code
    // Create Date column of date-time cells.
    FarPoint.Web.Spread.DateTimeCellType objDateCell = new FarPoint.Web.Spread.DateTimeCellType();
    objDateCell.FormatString = "M/dd/yyyy";
    FpSpread1.Sheets[0].Columns[1].CellType = objDateCell;
    
    VB
    Copy Code
    ' Create Date column of date-time cells.
    Dim objDateCell As New FarPoint.Web.Spread.DateTimeCellType()
    objDateCell.FormatString ="M/dd/yyyy"
    FpSpread1.Sheets(0).Columns(1).CellType = objDateCell
    
  3. Set the cell type for the Description column by adding the following code below the code you have already added:
    C#
    Copy Code
    // Create Description column of general cells.
    FarPoint.Web.Spread.GeneralCellType objGenCell = new FarPoint.Web.Spread.GeneralCellType();
    FpSpread1.Sheets[0].Columns[2].CellType = objGenCell;
    
    VB
    Copy Code
    ' Create Description column of general cells.
    Dim objGenCell As New FarPoint.Web.Spread.GeneralCellType()
    FpSpread1.Sheets(0).Columns(2).CellType = objGenCell
    
  4. Set the cell type for the Tax? and Cleared? columns by adding the following code below the code you have already added:
    C#
    Copy Code
    /// Create Tax? and Cleared? columns of check box cells.
    FarPoint.Web.Spread.CheckBoxCellType objCheckCell = new FarPoint.Web.Spread.CheckBoxCellType();
    FpSpread1.Sheets[0].Columns[3].CellType = objCheckCell;
    FpSpread1.Sheets[0].Columns[4].CellType = objCheckCell;
    
    VB
    Copy Code
    ' Create Tax? and Cleared? columns of check box cells.
    Dim objCheckCell As New FarPoint.Web.Spread.CheckBoxCellType()
    FpSpread1.Sheets(0).Columns(3).CellType = objCheckCell
    FpSpread1.Sheets(0).Columns(4).CellType = objCheckCell
    
  5. Set the cell type for the Debit, Credit, and Balance columns by adding the following code below the code you have already added:
    C#
    Copy Code
    // Create the Debit, Credit, and Balance columns of currency cells.
    FarPoint.Web.Spread.CurrencyCellType objCurrCell = new FarPoint.Web.Spread.CurrencyCellType();
    FpSpread1.Sheets[0].Columns[5].CellType = objCurrCell;
    FpSpread1.Sheets[0].Columns[6].CellType = objCurrCell;
    FpSpread1.Sheets[0].Columns[7].CellType = objCurrCell;
    
    VB
    Copy Code
    ' Create the Debit, Credit, and Balance columns of currency cells.
    Dim objCurrCell As New FarPoint.Web.Spread.CurrencyCellType()
    FpSpread1.Sheets(0).Columns(5).CellType = objCurrCell
    FpSpread1.Sheets(0).Columns(6).CellType = objCurrCell
    FpSpread1.Sheets(0).Columns(7).CellType = objCurrCell
    
  6. Save your project, then from the Debug menu choose Start to run your project.

Your ASP.NET page should look similar to the following picture.