If you have multiple sheets, you can remove a sheet or remove several sheets from the Spread component. There must always be at least one sheet in the component. The sheet index is zero-based. In code, you can simply change the sheet count or you can explicitly remove the sheet(s).
Removing an existing sheet does not change the default sheet names provided to the other sheets. For example, a Spread component with three sheets would by default name them Sheet1, Sheet2, and Sheet3. If you remove the second sheet, the names for the remaining sheets are Sheet1 and Sheet3. The indexes for the sheets are 0 and 1, because the sheet index is zero based. You can also hide a sheet. For more information, refer to Showing or Hiding a Sheet.To remove an existing sheet, complete the following instructions.
Return to the overview at Working with Sheets.
Using the Properties Window
- At design time, in the Properties window, select the Spread component.
- Select the Sheets property.
- Click the button to display the SheetView Collection Editor.
- In the Members list, select the sheet to remove.
- Click the Remove button to remove the sheet from the collection.
- Click OK to close the editor.
Using a Shortcut
Call the Sheets shortcut object Remove method (to remove the sheet from the SheetViewCollection for the component) and specify the sheet to remove.
Example
This example code removes the second sheet from a Spread component that has two or more sheets.
C# | Copy Code |
---|---|
// Remove the second sheet.
fpSpread1.Sheets.Remove(fpSpread1.Sheets[1]);
|
VB | Copy Code |
---|---|
' Remove the second sheet.
FpSpread1.Sheets.Remove(FpSpread1.Sheets(1))
|