Adding or Inserting a Column into Worksheet
Contents
[
Hide
]
In this topic, we will describe the basic feature of adding and inserting columns to the worksheets at runtime using the API of Aspose.Cells.GridDesktop. The basic difference between addition and insertion is that in addition, column is added at the end of the columns collection of the worksheet where as in insertion, column can be added to any specified position in the worksheet.
Adding a Column to Worksheet
To add a new column to the worksheet, please follow the steps below:
- Add Aspose.Cells.GridDesktop control to your Form
- Access any desired Worksheet
- Add Column to the Worksheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Adding column to the worksheet | |
sheet.AddColumn(); |
Inserting a Column into Worksheet
To insert a new column into worksheet at a specified position, please follow the steps below:
- Add Aspose.Cells.GridDesktop control to your Form
- Access any desired Worksheet
- Insert Column into Worksheet (at a specific position by specifying the index of the column where to insert it)
// Accessing first worksheet of the Grid
Aspose.Cells.GridDesktop.Worksheet sheet = gridDesktop1.Worksheets[0];
// Inserting column to the worksheet to the first position.
sheet.Cells.InsertColumn(0);