Spread Windows Forms 10.0 Product Documentation > Developer's Guide > Understanding the Spreadsheet Objects > Working with Sheets > Working with Multiple Sheets |
The component allows multiple sheets. You can specify the number of sheets with the Count property of the SheetViewCollection class. For example, you can set the Spread to have 5 sheets (and each sheet has a sheet name tab) using this code:
fpSpread1.Sheets.Count = 5;
You can specify properties for an individual sheet or for several sheets at a time. Use the SheetView class or the ActiveSheet shortcut in code. For more information, refer to Customizing the Individual Sheet Appearance.
You can name the sheets or use the default sheet names. The default sheet name is "Sheet1" and as other sheets are added, the sheet are named incrementally "Sheet2", "Sheet3", and so on. Use the SheetName property in the SheetView class to name the sheet programmatically.
To add a new sheet, refer to Adding a Sheet. To remove a sheet, refer to Removing a Sheet.
You can use code such as the following to copy a sheet to another Spread component.
FpSpread2.Sheets(0) = FpSpread1.Sheets(1)
Since the two sheets use the same SheetView object, any changes made in one sheet are automatically reflected in the other.
To return a sheet by name, you can use the SheetViewCollection.Find method as shown in the following code.
FpSpread1.Sheets.Find("Sheet1").Cells(0,0).Value = "test"
The FpSpread.Sheets property can be used when you wish to use an integer for the sheet value. This method has a SheetViewCollection object as its value and takes an integer as the indexer instead of a string for a sheet name.
For information about the display of the sheet names in the sheet name buttons, refer to Customizing the Sheet Name Tabs of the Component.