Add or Insert a Worksheet
In this topic, we will discuss the techniques to add or insert worksheets in an Excel file using Aspose.Cells.GridDesktop. The difference between adding and inserting worksheets is that adding a worksheet simply appends it to the end of the worksheets collection of the Excel file, whereas inserting means adding a worksheet at a specific position in the worksheets collection.
Adding a Worksheet
To add a worksheet using Aspose.Cells.GridDesktop, please follow the steps below:
- Add the Aspose.Cells.GridDesktop control to a form.
- Call the Worksheets collection’s Add method in the GridDesktop control.
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.
Inserting a Worksheet
To insert a worksheet using Aspose.Cells.GridDesktop, please follow the steps below:
- Add the Aspose.Cells.GridDesktop control to a form.
- Call the Worksheets collection’s Insert method in the GridDesktop control.
IMPORTANT: Microsoft Excel (97-2003 XLS) supports worksheets with up to 65,536 rows and 256 columns. Aspose.Cells.GridDesktop follows the same standards. In the Aspose.Cells.GridDesktop control, developers can add or insert worksheets with more rows and columns than the standard limit, but when they try to save the Grid data to an Excel file, an exception will be thrown. This means that only data contained within the 65,536 rows and 256 columns can be saved to an Excel XLS file using Aspose.Cells.GridDesktop. If you use XLSX (MS Excel 2007/2010) file format, there is no such limitation.