Add or Insert a Worksheet

Adding a Worksheet

To add a worksheet using Aspose.Cells.GridDesktop, please follow the steps below:

  1. Add Aspose.Cells.GridDesktop control to a form.
  2. Call the Worksheet collection’s Add method in the GridDesktop control.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Adding a worksheet to the Grid
int i = gridDesktop1.Worksheets.Add();
Worksheet sheet = gridDesktop1.Worksheets[i];

Many overloaded versions of the Add method are available. Using the above overloaded version, for example, a worksheet is added to the Excel file with a default sheet name. Using other overloaded versions of the Add method, it is possible to define the name as shown below in the example.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Adding a worksheet to the Grid with a specific name
Worksheet sheet1 = gridDesktop1.Worksheets.Add("AddWorksheetWithName");

Inserting a Worksheet

To insert a worksheet using Aspose.Cells.GridDesktop, please follow the steps below:

  1. Add the Aspose.Cells.GridDesktop control to a form.
  2. Call the Worksheets collection’s Insert method in the GridDesktop control.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Inserting a worksheet to Grid at first position of the worksheets collection
gridDesktop1.Worksheets.Insert(0);