添加或插入工作表中的列
Contents
[
Hide
]
在本主题中,我们将描述使用Aspose.Cells.GridDesktop的API在运行时向工作表添加和插入列的基本功能。添加和插入之间的基本区别在于,添加时列被添加到工作表的列集合的末尾,而插入时列可以添加到工作表中的任何指定位置。
向工作表添加列
要向工作表添加新列,请按照以下步骤进行:
- 向您的表单中添加Aspose.Cells.GridDesktop控件
- 访问任何所需的工作表
- 在 工作表 中添加 列
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(); |
在工作表中插入列
要在指定位置向工作表插入新列,请按照以下步骤执行:
- 向您的表单中添加Aspose.Cells.GridDesktop控件
- 访问任何所需的工作表
- 向 工作表 中插入 列 (通过指定要插入的列的索引位置)
// 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);