在工作表中添加或插入行
Contents
[
Hide
]
与我们之前的主题之一类似,本主题描述了使用 Aspose.Cells.GridDesktop 的 API 在运行时向工作表添加和插入行的功能。添加和插入之间的基本区别在于,另外,在工作表的行集合的末尾添加一行,而在插入中,可以将行添加到工作表中的任何指定位置。
向工作表添加行
要向工作表添加新行,请按照以下步骤操作:
- 将 Aspose.Cells.GridDesktop 控件添加到您的形式
- 访问任何想要的工作表
- 添加排到工作表
This file contains hidden or 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 row to the worksheet | |
sheet.AddRow(); |
在工作表中插入一行
要在工作表的指定位置插入新行,请按照以下步骤操作:
- 将 Aspose.Cells.GridDesktop 控件添加到您的形式
- 访问任何想要的工作表
- 插入排进入工作表(通过指定插入行的索引在特定位置)
// Accessing first worksheet of the Grid
Aspose.Cells.GridDesktop.Worksheet sheet = gridDesktop1.Worksheets[0];
// Inserting row to the worksheet to the first position.
sheet.Cells.InsertRow(0);