Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Understanding the Spreadsheet Objects > Working with Sheets > Adding a Sheet |
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.
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 of the Component.
To add a sheet to the component, complete the following instructions.
A new sheet named SheetViewn (where n is an integer) is added to the component.
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); |
VB |
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) |