Spread Windows Forms 15.0
Spread Windows Forms 15.0 Product Documentation / Developer's Guide / Sheets / Adding a Sheet
In This Topic
    Adding a Sheet
    In This Topic

    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.

    Using the Properties Window

    1. At design time, in the Properties window, select the Spread component.
    2. Select the Sheets property.
    3. Click the button to display the SheetView Collection Editor.
    4. Click the Add button to add a sheet to the collection.

      A new sheet named SheetViewn (where n is an integer) is added to the component.

    5. If you want to change the name of the new sheet, click the SheetName property in the property list, and then type the new name for the sheet.
    6. Click OK to close the editor.

    Method to use

    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.

    Example

    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)
    
    See Also