ワークシートで Cells にアクセスする
Contents
[
Hide
]
これまでワークシート、行、列の操作について説明してきましたが、今度はさらに深くセルについて説明します。したがって、このトピックでは、セルにアクセスする基本的な機能からセルについての議論を開始します。
ワークシートで Cells にアクセスする
Aspose.Cells.GridDesktop の API を使用して、ワークシートの任意のセルにアクセスできます。セルにアクセスするには、次の 3 つの方法が考えられます。
- Cell名を使用
- Cell の行と列のインデックスを使用する
- 集中する Cell
上記の 3 つのアプローチを 1 つずつ説明しましょう。
Cell名を使用
ワークシート内のすべてのセルには、一意の名前があります。たとえば、A1、A2、B1、B2 などです。Aspose.Cells.GridDesktop を使用すると、開発者はセル名を使用して目的のセルにアクセスできます。セル名を (インデックスとして) に渡すだけです。Cellsのコレクションワークシート.
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 the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing a cell using its name | |
GridCell cell = sheet.Cells["A1"]; |
Cell の行インデックスと列インデックスの使用
ワークシート内のセルは、行インデックスと列インデックスの位置を使用して認識することもできます。セルの行インデックスと列インデックスをCellsのコレクションワークシート.
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 the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing a cell using its row and column indices | |
GridCell cell = sheet.Cells[1, 1]; |
集中する Cell
アクセスするセルが正確にわからない場合。次に、Aspose.Cells.GridDesktop を使用すると、現在ユーザーがフォーカスしているセルにアクセスすることもできます。この機能を使用すると、ユーザーが任意のセルを選択できるようになり、バックエンドでそのセルにアクセスできるようになります。を使用することで簡単に実現できます。GetFocusedCellの方法ワークシート.
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 the worksheet of the Grid that is currently active | |
Worksheet sheet = gridDesktop1.GetActiveWorksheet(); | |
// Accessing a cell that is currently in focus | |
GridCell cell = sheet.GetFocusedCell(); |