GridWeb Cell の Hyperlink オブジェクトにアクセスする
Contents
[
Hide
]
考えられる使用シナリオ
次の 2 つの方法を使用して、セルにハイパーリンクが含まれているかどうかを確認できます。これらのメソッドは、セルにハイパーリンクが含まれていない場合は null を返し、ハイパーリンクが含まれている場合は GridHyperlink オブジェクトを返します。
- GridHyperlinkCollection.GetHyperlink(GridCell セル)
- GridHyperlinkCollection.GetHyperlink(int 行、int 列)
新規または既存のウィンドウでハイパーリンクを開く
Excelファイルに、次のようなURLにリンクするハイパーリンクが含まれている場合http://wwww.aspose.com/それを GridWeb にロードすると、ハイパーリンクは target 属性が設定された状態でレンダリングされます。_空欄。つまり、GridWeb セルのハイパーリンクをクリックすると、既存のウィンドウではなく新しいウィンドウで開きます。次のデバッグ ウィンドウで GridHyperlink.Target プロパティを確認してください。また、ハイパーリンクを既存のウィンドウで開きたい場合は、GridHyperlink.Target を次のように設定してください。_自己。
GridWeb Cell の Hyperlink オブジェクトにアクセスする
次のサンプル コードは、セル A1 のハイパーリンクにアクセスします。セル A1 にハイパーリンクが含まれている場合は GridHyperlink オブジェクトが返され、それ以外の場合は null が返されます。
サンプルコード
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 | |
// Access first worksheet of gridweb and cell A1 | |
GridWorksheet sheet = GridWeb1.WorkSheets[0]; | |
GridCell cellA1 = sheet.Cells["A1"]; | |
// Access hyperlink of cell A1 if it contains any | |
GridHyperlink cellHyperlink = sheet.Hyperlinks.GetHyperlink(cellA1); | |
if (cellHyperlink == null) | |
{ | |
Label1.Text = "Cell A1 does not have any hyperlink"; | |
} | |
else | |
{ | |
// Access hyperlink properties e.g. address | |
string hyperlinkAddress = cellHyperlink.Address; | |
Label1.Text = "Address of hyperlink in cell A1 :" + hyperlinkAddress; | |
} |