You can add a sheet or add several sheets to the component. By default, the component has one sheet, named Sheet 1 and referenced as sheet index 0. The sheet index is zero-based. If you are using custom sheet names be sure to specify the name of the sheet.
In code, you can simply change the number of sheets by changing the Count property or you can explicitly add the sheet(s) by defining new sheets or by using the Add method. The following instructions describe how to add a sheet.
For information on removing a sheet, refer to Removing a Sheet.
Return to the sheet appearance overview at Customizing the Appearance of the Sheet.
Using the Properties Window
- At design time, in the Properties window, select the Sheets property for the FpSpread component.
- Click the button to display the SheetView Collection Editor.
- Click the Add button to add a sheet to the collection.
A new sheet named Sheetn (where n is an integer) is added to the component.
- 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.
- Click OK to close the editor.
Using Code
- Create a new SheetView object.
- If you want to do so, set properties for the sheet, such as its name.
- Use the Add method with the FpSpread component Sheets shortcut to add the new SheetView object to the collection of sheets (SheetViewCollection) for the component.
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.Web.Spread.SheetView newsheet = new FarPoint.Web.Spread.SheetView(); newsheet.SheetName = "North"; newsheet.ColumnCount = 10; newsheet.RowCount = 100; // Add the new sheet to the component. FpSpread1.Sheets.Add(newsheet); |
VB | Copy Code |
---|---|
' Create a new sheet. Dim newsheet As New FarPoint.Web.Spread.SheetView() newsheet.SheetName = "North" newsheet.ColumnCount = 10 newsheet.RowCount = 100 ' Add the new sheet to the component. FpSpread1.Sheets.Add(newsheet) |
Using the Spread Designer
- Select the Data menu. Click on the Insert icon.
- Click the Insert Sheet option.
A new sheet named Sheetn (where n is an integer) is added to the component.
- If you want to change the name of the new sheet, click the new sheet in the Properties for Sheetn list, and change the SheetName property in the property list.
- Click Apply and Exit to close the Spread Designer.