Spread Windows Forms 8.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", etc. 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 like the following to make a copy of one sheet into another Spread component.
FpSpread2.Sheets(0) = FpSpread1.Sheets(1)
Since they use the same SheetView object, all changes to one sheet would reflect in the other sheet.
The FpSpread.Sheets property, which has a SheetViewCollection object as its value, must take an integer as the indexer, and not a string for a sheet name. But you can use the SheetViewCollection.Find method to find a SheetView object by its name.
FpSpread1.Sheets.Find("Sheet1").Cells(0,0).Value = "test"
For information about the display of the sheet names in the sheet name buttons, refer to Customizing the Sheet Name Tabs of the Component.