Introduction
Worksheets are an integral part of Aspose.Grid.Web. All data is managed and stored in the form of worksheets. Aspose.Grid.Web allows developers to add one or more worksheets to Aspose.Grid.Web control. In this topic, we will discuss the simplest approaches to add worksheets to Aspose.Grid.Web.
Adding a Worksheet
Without Specifying Sheet Name
The most simple approach is to add a worksheet to Aspose.Grid.Web by just calling the Add method of WebWorksheets collection of GridWeb control. Using this approach, new worksheets with default names (that is Sheet1, Sheet2, Sheet3 and so on) are added to GridWeb control.
Example:
[C#]
//Adding a worksheet to GridWeb
int sheetIndex = GridWeb1.WebWorksheets.Add();
[VB.NET]
'Adding a worksheet to GridWeb
Dim sheetIndex As Integer = GridWeb1.WebWorksheets.Add()
The output of above code snippet is displayed in the figure shown below:
|
Figure: A worksheet added to GridWeb with Default Name
|
With Specified Sheet Name
If develoeprs want to add a worksheet to GridWeb control with a specific sheet name instead of using default naming scheme of Aspose.Grid.Web then they can call another overloaded version of Add method that takes the specified Sheet Name for the newly added worksheet. For an instance, in the example below, we have added a worksheet named as Invoice to GridWeb control.
Example:
[C#]
//Adding a worksheet to GridWeb with a specified name
int sheetIndex = GridWeb1.WebWorksheets.Add("Invoice");
[VB.NET]
'Adding a worksheet to GridWeb with a specified name
Dim sheetIndex As Integer = GridWeb1.WebWorksheets.Add("Invoice")
The output of above code snippet is displayed in the figure shown below:
|
Figure: A worksheet added to GridWeb with Specified Name
|
NOTE: Add method returns the Index of the newly added worksheet, which can be used to access the instance of this worksheet. For more details about accessing worksheets, please Click Here.