Get Hyperlinks in Range
Contents
[
Hide
]
Get Hyperlinks in Range
To get hyperlinks in range, use the getHyperlinks() property of the Range class. The getHyperlinks() property gets all the hyperlinks in the selected range.
The following code snippet shows how to get all hyperlinks in the selected range.
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
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
# Load Source Excel file | |
workbook = Workbook(source_directory + "HyperlinksSample.xlsx") | |
# Access first worksheet | |
worksheet = workbook.getWorksheets().get(0) | |
# Create a range A2:B3 | |
range = worksheet.getCells().createRange("A2", "B3") | |
# Get Hyperlinks in range | |
hyperlinks = range.getHyperlinks() | |
for link in hyperlinks: | |
print(str(link.getArea()) + " : " + str(link.getAddress())) |