Spread Windows Forms 15.0
Spread Windows Forms 15.0 Product Documentation / Developer's Guide / Sheets / Working with Multiple Sheets
In This Topic
    Working with Multiple Sheets
    In This Topic

    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.

    C#
    Copy Code
    fpSpread1.Sheets.Count = 5;
    
    Visual Basic
    Copy Code
    FpSpread1.Sheets.Count = 5
    

    You can set the properties of each sheet in code by using ActiveSheet property of the SheetView or FpSpread class.

    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 of the SheetView class to name the sheet programmatically.The addition and removal of sheets are described below.

    The Sheets property of the FpSpread class returns a SheetViewCollection object that holds all the sheets of the control.In the Sheets property, specify an integer starting with "0" as an index to refer to a specific sheet.

    The following sample code copies the sheet with the index "1" of the fpSpread1 control (second sheet) to the sheet with the index "0" of the fpSpread2 control (the first sheet).Since both refer to the same SheetView object in this sample code, changes made to one sheet gets reflected to the other sheet as well.

    C#
    Copy Code
    fpSpread2.Sheets[0] = fpSpread1.Sheets[1];
    
    Visual Basic
    Copy Code
    FpSpread2.Sheets(0) = FpSpread1.Sheets(1)
    

    To return a sheet by name, you can use the Find method of the SheetViewCollection class as shown in the following code.

    C#
    Copy Code
    fpSpread1.Sheets.Find("Sheet1").Cells[0, 0].Value = "test";
    
    Visual Basic
    Copy Code
    FpSpread1.Sheets.Find("Sheet1").Cells(0, 0).Value = "test"
    

    For information about the display of the sheet names, kindly refer to "Customizing the Sheet Name Tabs".

    See Also