The general cell is the default cell type for the cells in the sheets. Unless you specify another cell type, it is the general cell type that is assigned to the cells. The general cell can be used as is for entering text or numbers where formatting is not critical or the type of data is not tied to a specific data type. For specific cell types where formatting is important, see the CurrencyCellType, DateTimeCellType, NumberCellType, and PercentCellType cells.
You use the GeneralCellType class to set the general cell and its properties.
With the general cell you can format the displayed values regardless of the user put. The general cell type includes a formatter that takes the data entered by the user and coerces it into one of the known formats and data types. This frees the developer from worrying about setting cell types because the general cell type handle inputs of many kinds. The openness of the general cell can be restricted a bit if the developer wants to allow the user to enter data in any acceptable format, but wants it to be formatted and displayed in a specific way. To do this, the developer simply specifies a format string for the general cell type and the general formatter parses the user-entered data, but when the data is displayed, the developer-specified format is used rather than the format used by the end user.You could use the FormatString property. Here is an example in Visual Basic code:
Dim gnrlcell As New FarPoint.Win.Spread.GeneralCellType
gnrlcell.FormatString = "#,###.00"
FpSpread1.Sheets(0).Cells(1, 1).CellType = gnrlcell
If you want to customize how the general cell displays the data, you can work with the format string. The general cell type includes a formatter that takes the data entered by the user and coerces it into one of the known formats and data types. If you want to allow the user to enter data in any acceptable format, but want it to be formatted and displayed in a specific way, you can adjust the formatter for the general cell type. To do this, specify a format string for the general cell and the general formatter parses the user-entered data, but when the data is displayed, your custom format is used rather than the format used by the end user.
For more information on the properties and methods of this cell type, refer to the GeneralCellType class.
Using the Properties Window
- At design time, in the Properties window, select the Spread component.
- Select the Sheets property.
- Click the button to display the SheetView Collection Editor.
- In the Members list, select the sheet in which the cells appear.
- In the property list, select the Cells property and then click the button to display the Cell, Column, and Row Editor.
- Select the cells for which you want to set the cell type.
- In the property list, select the CellType property and choose the General cell type.
- Expand the list of properties under the CellType property. Select and set these specific properties as needed.
- Click OK to close the Cell, Column, and Row Editor.
- Click OK to close the SheetView Collection Editor.
- Define the general cell by creating an instance of the GeneralCellType class.
- Assign the general cell type to a cell or range of cells by setting the CellType property for a cell, column, row, or style to the GeneralCellType object.
This example sets a cell to be a general cell.
FarPoint.Win.Spread.CellType.GeneralCellType gnrlcell = new FarPoint.Win.Spread.CellType.GeneralCellType();
fpSpread1.ActiveSheet.Cells[1, 1].CellType = gnrlcell;
Dim gnrlcell As New FarPoint.Win.Spread.CellType.GeneralCellType() FpSpread1.ActiveSheet.Cells(1, 1).CellType = gnrlcell
Using the Spread Designer
- Select the cell or cells in the work area.
- In the property list, in the Misc category, select CellType. From the drop-down list, choose the General cell type. Now expand the CellType property and various properties are available that are specific to this cell type. Select and set those properties as needed.
Or right-click on the cell or cells and select Cell Type. From the list, select General. In the CellType editor, set the properties you need. Click Apply.
- From the File menu choose Apply and Exit to apply your changes to the component and exit Spread Designer.