アクセス ワークシート Cells

ワークシートで Cells にアクセスする

各ワークシートには、実際には GridCell オブジェクトのコレクションである Cells という名前のプロパティが含まれており、GridCell オブジェクトは Aspose.Cells.GridWeb のセルを表します。 Aspose.Cells.GridWeb を使用して任意のセルにアクセスできます。 2 つの好ましい方法があり、それぞれについて以下で説明します。

Cell名を使用

すべてのセルには固有の名前があります。たとえば、A1、A2、B1、B2 などです。Aspose.Cells.GridWeb を使用すると、開発者はセル名を使用して目的のセルにアクセスできます。セル名を (インデックスとして) GridWorksheet の Cells コレクションに渡すだけです。

// 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 コレクションに渡すだけです。このアプローチは、上記のアプローチよりも高速です。

// 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/>";