检测超链接类型
Contents
[
Hide
]
检测超链接类型
Excel 文件可以有不同类型的超链接,如外部、单元格引用、文件路径等。Aspose.Cells 支持检测超链接类型的功能。超链接的类型由目标模式类型枚举。这目标模式类型枚举具有以下成员。
- 外部:外部链接
- 文件路径:文件\文件夹的本地和完整路径。
- 电子邮件: 电子邮件
- CellReference:链接到单元格或命名区域。
要检查超链接的类型,超级链接类提供了链接类型返回类型为目标模式类型.下面的代码片段演示了使用链接类型通过使用这个属性源文件.
源代码
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 | |
//source directory | |
string SourceDir = RunExamples.Get_SourceDirectory(); | |
Workbook workbook = new Workbook(SourceDir + "LinkTypes.xlsx"); | |
// Get the first (default) worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Create a range A2:B3 | |
Range range = worksheet.Cells.CreateRange("A1", "A7"); | |
// Get Hyperlinks in range | |
Hyperlink[] hyperlinks = range.Hyperlinks; | |
foreach (Hyperlink link in hyperlinks) | |
{ | |
Console.WriteLine(link.TextToDisplay + ": " + link.LinkType); | |
} |
以下是上面给出的代码片段生成的输出。
控制台输出
LinkTypes.xlsx: FilePath </br>
C:\Windows\System32\cmd.exe: FilePath </br>
C:\Program Files\Common Files: FilePath </br>
'Test Sheet'!B2: CellReference </br>
FullPathExample: CellReference </br>
https://products.aspose.com/cells/ : External </br>
mailto:test@test.com?subject=TestLink: Email </br>