Çalışma Sayfasında Hyperlinkleri Yönetme
Hyperlinkler Ekleme
Aspose.Cells.GridDesktop kullanarak bir hücreye bağlantı eklemek için lütfen aşağıdaki adımları izleyin:
- Form‘unuza Aspose.Cells.GridDesktop kontrolünü ekleyin
- Herhangi bir istenen Çalışma Sayfası‘na erişin
- Bağlantı eklenecek çalışsayfadaki istenen Hücre‘ye erişin
- Bağlantı eklenmek istenen hücreye bir değer ekleyin
- Bağlantı uygulanacak hücreyi belirterek Çalışsayfa‘ya Bağlantı ekleyin
Çalışsayfa nesnesindeki Bağlantılar koleksiyonu, aşırı yüklenmiş bir Ekle yöntemi sağlar. Geliştiriciler, belirli ihtiyaçlarına göre Ekle yönteminin herhangi bir aşırı yüklenmiş sürümünü kullanabilir.
Aşağıdaki kod, çalışsayfanın B2 ve C3 hücrelerine bağlantı ekleyecektir.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing cell of the worksheet | |
GridCell cell = sheet.Cells["b2"]; | |
GridCell cell2 = sheet.Cells["c3"]; | |
// Modifying the width of the column of the cell | |
sheet.Columns[cell.Column].Width = 160; | |
sheet.Columns[cell2.Column].Width = 160; | |
// Adding a value to the cell | |
cell.Value = "Aspose Home"; | |
cell2.Value = "Aspose Home"; | |
// Adding a hyperlink to the worksheet containing cell name and the hyperlink URL with which the cell will be linked | |
sheet.Hyperlinks.Add("b2", "www.aspose.com"); | |
sheet.Hyperlinks.Add("c3", "www.aspose.com"); |
Bağlantıları Erişme
Bir hücreye bağlantı eklendikten sonra, bağlantıya erişilmesi ve çalışma zamanında değiştirilmesi de gerekebilir. Bunun için geliştiriciler, Basitleştirilmiş Çalışsayfa’nın Bağlantılar koleksiyonundan bağlantıya basitçe erişebilirler ve bağlanacak hücreyi belirterek bağlantıyı değiştirebilirler (hücre adını veya satır ve sütun numarası olarak konumunu kullanarak). Bağlantıya erişildiğinde geliştiriciler, çalışma zamanında URL’sini değiştirebilirler.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
// Accessing a hyperlink added to "c3,b2" cells (specified using its row & column number) | |
Aspose.Cells.GridDesktop.Data.GridHyperlink hyperlink1 = sheet.Hyperlinks[2, 2]; | |
Aspose.Cells.GridDesktop.Data.GridHyperlink hyperlink2 = sheet.Hyperlinks[1, 1]; | |
if (hyperlink1 != null && hyperlink2 != null) | |
{ | |
// Modifying the Url of the hyperlink | |
hyperlink1.Url = "www.aspose.com"; | |
hyperlink2.Url = "www.aspose.com"; | |
MessageBox.Show("Hyperlinks are accessed and URL's are: \n" + hyperlink1.Url + "\n" + hyperlink2.Url); | |
} | |
else | |
{ | |
MessageBox.Show("No hyperlinks are found in sheet. Add hyperlinks first."); | |
} |
Bağlantıları Kaldırma
Mevcut bir bağlantıyı kaldırmak için, geliştiriciler basitçe istenen çalışma sayfasına erişebilir ve ardından Bağlantılar koleksiyonundan bağlantıyı belirterek (adını veya satır ve sütun numarasını kullanarak) bağlantıyı Kaldırabilir.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing first worksheet of the Grid | |
Worksheet sheet = gridDesktop1.Worksheets[0]; | |
if (sheet.Hyperlinks.Count > 0) | |
{ | |
// Removing hyperlink from "c3" cell | |
sheet.Hyperlinks.Remove(2, 2); | |
MessageBox.Show("Hyperlink in C3 cell has been removed."); | |
} | |
else | |
{ | |
MessageBox.Show("No hyperlinks are found in sheet to remove. Add hyperlinks first."); | |
} |