行と列の挿入
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); |
列の挿入
ワークシートの任意の位置に列を挿入するには:
- Web フォームに Aspose.Cells.GridWeb コントロールを追加します。
- 列を追加するワークシートにアクセスします。
- 列が挿入される列インデックスを指定して列を挿入します。
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メソッドを使用して、それぞれワークシートに複数の行や列を挿入することもできます。