Add Worksheets
Adding a Worksheet
Without Specifying Sheet Name
The simplest way to add a worksheet to Aspose.Cells.GridWeb is to call the GridWorksheetCollection collection’s Add method in the GridWeb control. This creates worksheets that use default names (that is Sheet1, Sheet2, Sheet3 and so on) and adds them to the GridWeb control.
Output: a worksheet with default name has been added to GridWeb
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Adding a worksheet to GridWeb without specifying name | |
int sheetIndex = GridWeb1.WorkSheets.Add(); | |
GridWorksheet sheet = GridWeb1.WorkSheets[sheetIndex]; | |
Label1.Text = sheet.Name + " worksheet is added at index " + sheetIndex + ". <br/>"; |
With Specified Sheet Name
To add a worksheet with a specific name to the GridWeb control instead of using the default naming scheme, call an overloaded version of the Add method that takes the specified SheetName. For an instance, the example below adds a worksheet named Invoice.
Output: a worksheet with a specified name has been added to GridWeb
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Adding a worksheet to GridWeb with a specified name | |
if (GridWeb1.WorkSheets["Teachers"] == null) | |
{ | |
GridWorksheet sheet1 = GridWeb1.WorkSheets.Add("Teachers"); | |
Label1.Text += sheet1.Name + " worksheet is added at index " + sheet1.Index + ". <br/>"; | |
} |