アクセス ワークシート Cells
Contents
[
Hide
]
このトピックでは、Aspose.Cells.GridWeb の最も基本的な機能であるセルへのアクセスを見て、セルについて説明します。
ワークシートで Cells にアクセスする
各ワークシートには、実際には GridCell オブジェクトのコレクションである Cells という名前のプロパティが含まれており、GridCell オブジェクトは Aspose.Cells.GridWeb のセルを表します。 Aspose.Cells.GridWeb を使用して任意のセルにアクセスできます。 2 つの好ましい方法があり、それぞれについて以下で説明します。
Cell名を使用
すべてのセルには固有の名前があります。たとえば、A1、A2、B1、B2 などです。Aspose.Cells.GridWeb を使用すると、開発者はセル名を使用して目的のセルにアクセスできます。セル名を (インデックスとして) GridWorksheet の Cells コレクションに渡すだけです。
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 worksheet of the Grid that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Accessing "A1" cell of the worksheet | |
GridCell cell = sheet.Cells["A1"]; | |
// Display cell name and value | |
Label1.Text += "Cell Value of " + cell.Name +" is " + cell.StringValue + "<br/>"; |
行と列のインデックスの使用
セルは、行インデックスと列インデックスの位置によっても認識できます。セルの行と列のインデックスを GridWorksheet の Cells コレクションに渡すだけです。このアプローチは、上記のアプローチよりも高速です。
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 worksheet of the Grid that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Accessing "B1" cell of the worksheet using its row and column indices | |
GridCell cell = sheet.Cells[0, 1]; | |
// Display cell name and value | |
Label1.Text += "Cell Value of " + cell.Name +" is " + cell.StringValue + "<br/>"; |