Spread Windows Forms 7.0 Product Documentation
Understanding the Types of Sheet Models
Support Options
Spread Windows Forms 7.0 Product Documentation > Developer's Guide > Understanding the Underlying Models > Understanding the Types of Sheet Models

Glossary Item Box

The Spread component provides the following models that provide a basis for much of the customization that is possible with the component.:

Sheet Model Classes and Interface Description
Axis model

BaseSheetAxisModel

DefaultSheetAxisModel

ISheetAxisModel

Basis for how the sheet of cells is structured in terms of rows and columns. For more information, see Understanding the Axis Model.
Data model

BaseSheetDataModel

DefaultSheetDataModel

ISheetDataModel

Basis for the manipulation of data in the cells in the sheet. For more information, see Understanding the Data Model.
Selection model

BaseSheetSelectionModel

DefaultSheetSelectionModel

ISheetSelectionModel

Basis for the behavior of and interaction of selected cells in the sheet. For more information, see Understanding the Selection Model.
Span model

BaseSheetSpanModel

DefaultSheetSpanModel

ISheetSpanModel

Basis for how cells in the sheet are spanned. For more information, see Understanding the Span Model.
Style model

BaseSheetStyleModel

DefaultSheetStyleModel

ISheetStyleModel

Basis for the appearance of the cells in the sheet. For more information, see Understanding the Style Model.

It might help for you think of the sheet (SheetView object) as a composite of the five underlying models (Axis, Data, Selection, Span, and Style). The Axis model handles everything to do with the Columns and Rows (for example, the column width, row height, and whether a row or column is visible). Similarly, the Data model handles everything to do with the data (for example, the value, the formula, and any optional notes or tags in a cell) and contains the data in the sheet. The Selection model handles any cell range selections that are made, and Span models handles any spanned cells. The Style model handles the appearance settings for the cells (for example, the background color, the font, and the cell type). So, everything you do to the model is automatically updated in the sheet and most of the aspects of the sheet that you can modify are updated in the model. This is also true for Cell, Row, and Column object settings, too. Most of the aspects changed with these objects automatically changes the setting in the corresponding sheet model and vice versa. If you add columns to the data model, then they are added to the sheet. This is true, even down to the parameters; for example the row and column arguments in the GetValue and SetValue methods for the data model are the same indexes as that of the rows and columns in the sheet as long as the sheet is not sorted.

Not everything in the Spread namespace is in the models. For example, there are aspects of the overall component, the sheet tabs and the sheet background color, and grid lines, that are not in the models. But the relevant pieces of information about a given cell, both about the data in the cells and about the appearance of the cells, are in the models. The data area of the spreadsheet has its own set of models, and the row headers and column headers are considered two more such groups having models assigned to each of them, and the sheet corner is another with its own set of models.

Each model has a has a base model class and a default model class and an interface. The default model is given as the model with which you most likely develop; this provides the default features that the component offers and is used for small customizations to the models. The base model is the base on which the default model is created and is for creating custom models from scratch. The base model has the fewest built-in features, and the default model extends the base model. If you want to provide different features or customize the behavior or appearance of your application, you can extend the base models to create new classes. For example you may do this to create a template component for all the developers in your organization. By creating your own class based on one of the base models, you can create the customized class and provide it to all the developers to use. Typically, if you are editing the models, use the default model classes. But if you want to create a custom model (from scratch), use the base model classes.

Each default model class contains the implementation of the interface for that model type as well as additional optional interfaces. Most of the functionality (that is, formulas, data binding, XML serialization, etc.) is optional in the model class, and is implemented in separate interfaces from the main model interfaces (such as ISheetDataModel) so that if you want to implement your own model class you can pick and choose which pieces of functionality you have in your model.

It is important for the models to stay in sync with each other, so that the row count and column count is consistent among the models making up the sheet. The SheetView object listens for the ISheetDataModel.Change event from the SheetView.DocumentModels.Data property, and updates the other models accordingly when the row count or column count changes due to any of these:

If the models get out of sync, then index out-of-range exceptions can be caused by code trying to get information about nonexistent rows or columns.

For more information on creating a custom model for a sheet, refer to Creating a Custom Sheet Model.
© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.