插入行和列
Contents
[
Hide
]
本主题解释了如何使用Aspose.Cells.GridWeb API将新行和列插入工作表。可以在工作表的任何位置插入行或列。
插入行
在工作表的任何位置插入行:
- 将Aspose.Cells.GridWeb控件添加到Web表单。
- 访问要添加行的工作表。
- 通过指定要插入行的行索引来插入行。
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 the reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Get row index entered by user | |
int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim()); | |
// Add row at specified index | |
sheet.Cells.InsertRow(rowIndex); |
插入列
在工作表的任何位置插入列:
- 将 Aspose.Cells.GridWeb 控件添加到 Web 表单中。
- 访问要添加列的工作表。
- 通过指定要插入列的列索引来插入列。
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 the reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Get column index entered by user | |
int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim()); | |
// Add column at specified index | |
sheet.Cells.InsertColumn(columnIndex); |
您还可以使用 InsertRows/InsertColumns 方法相应地将多行/列插入到工作表中。