删除行和列
Contents
[
Hide
]
本主题演示了如何使用Aspose.Cells.GridWeb API从工作表中删除行和列。借助该功能,开发人员可以在运行时删除行或列。
删除行
要从工作表中删除行:
- 将 Aspose.Cells.GridWeb 控件添加到 Web 表单中。 1.访问要从中删除行的工作表。
- 通过指定其行索引来从工作表中删除行。
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()); | |
// Delete row at specified index | |
sheet.Cells.DeleteRow(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()); | |
// Delete column at specified index | |
sheet.Cells.DeleteColumn(columnIndex); |
您还可以使用DeleteRows/DeleteColumns方法将多行/列删除到工作表中。