You can add a sheet or add several sheets to the Spread component. By default, the component has one sheet, named Sheet 1 and referenced as sheet index 0. The sheet index is zero-based. In code, you can simply change the sheet count or you can explicitly add the sheet(s). If you are using custom sheet names be sure to specify the name of the sheet.
The user is allowed to add new sheets by default. They can do this by clicking on the new sheet icon on the tab strip next to the sheet name (provided the tab strip is visible). If the sheet count is greater than 1, the tab strip is displayed by default. You can change this by setting the TabStripPolicy property. You can prevent the user from adding new sheets by setting the TabStripInsertTab property to false.
You can use the Add method to add a new sheet to the SheetViewCollection for the component. You can also use the AddNewSheetView method add a sheet.
For more information on how the sheet names appear in the sheet tabs, and how to customize the sheet tabs, refer to Customizing the Sheet Name Tabs.
A new sheet named SheetViewn (where n is an integer) is added to the component.
Create an instance of the SheetView class that represents a sheet, and set each property of the class (such as the sheet name).
Add the created sheet with the Add method of SheetViewCollection class referenced by Sheets property of FpSpread class.
This example code adds a new sheet to the component, then names the sheet "North" and sets it to have 10 columns and 100 rows.
C# |
Copy Code
|
---|---|
// Create a new sheet FarPoint.Win.Spread.SheetView newsheet = new FarPoint.Win.Spread.SheetView(); newsheet.SheetName = "North"; newsheet.ColumnCount = 10; newsheet.RowCount = 100; // Add the new sheet to the component fpSpread1.Sheets.Add(newsheet); |
Visual Basic |
Copy Code
|
---|---|
' Create a new sheet Dim newsheet As New FarPoint.Win.Spread.SheetView() newsheet.SheetName = "North" newsheet.ColumnCount = 10 newsheet.RowCount = 100 ' Add the new sheet to the component FpSpread1.Sheets.Add(newsheet) |