Get Hyperlinks in Range
Contents
[
Hide
]
Get Hyperlinks in Range
The Range class provides a getHyperlinks() property getter which gets all the hyperlinks in the selected range. You may also delete the Hyperlink by calling the Hyperlink.delete() method.
Sample Code
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-Java | |
// Instantiate a Workbook object | |
// Open an Excel file | |
Workbook workbook = new Workbook(sourceDir + "HyperlinksSample.xlsx"); | |
// Get the first (default) worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Create a range A2:B3 | |
Range range = worksheet.getCells().createRange("A2", "B3"); | |
// Get Hyperlinks in range | |
Hyperlink[] hyperlinks = range.getHyperlinks(); | |
for (Hyperlink link : hyperlinks){ | |
System.out.println(link.getArea() + " : " + link.getAddress()); | |
// To delete the link, use the Hyperlink.Delete() method. | |
link.delete(); | |
} | |
workbook.save(outputDir + "HyperlinksSample_out.xlsx"); |