Hyperlinks in Excel file

Hi Team,

I’m using Aspose Cells (Java) for reading hyperlinks in my excel file.
I’m using the below code, but unable to read hyperlinks in a SmartArt, Images, WordArt etc. I’m only able to parse hyperlinks in exact cells. Can you assist with me with ways to identify hyperlinks in other objects as well.

Also, can we identify if the hyperlink is Internal (pointing to a cell in same excel) or External?

Code Used

Workbook wb = new Workbook(dataDir + fileName);
wsCount = wb.getWorksheets().getCount();
for(int ws = 0; ws<wsCount; ws++){
Worksheet worksheet = wb.getWorksheets().get(ws);
hyperlinkCount = worksheet.getHyperlinks().getCount();
for(int i=0;i<hyperlinkCount;i++){
linkName = worksheet.getHyperlinks().get(i).getTextToDisplay();
linkURL = worksheet.getHyperlinks().get(i).getAddress();
System.out.println(removeSpecialChars(linkName)+ " - "+linkURL);
}
}

Sample File
testHyper2.zip (233.5 KB)

Thanks,
Vineet.

@vineet992

Please try the following code, it should help you get the hyperlink of any shape. The code works fine with your Excel file as I have tested it.

Java

Workbook wb = new Workbook(dirPath + "testHyper2.xlsm");

Worksheet worksheet = wb.getWorksheets().get(1);

int cnt = worksheet.getShapes().getCount();

for(int i=0; i < cnt; i++)
{
	Shape sh = worksheet.getShapes().get(i);
	
	System.out.println("Shape Name: " + sh.getName());
	System.out.println(sh.getHyperlink().getAddress());
}

Console Output

Shape Name: Diagram 1
http://go.microsoft.com/fwlink/?LinkID=219472&clcid=0x409
Shape Name: Picture 3
https://www.bing.com/search?q=bookmarks+in+ie+edge&form=EDGTCT&qs=PF&cvid=915754146fc34daab1f0a859fe95b532&cc=US&setlang=en-US
Shape Name: Rectangle 4
http://smartart.com

@shakeel.faiz

Thanks for your response.
If you can notice, diagram1 is an smartart, which has 5 diagrams in it. Diagram1 has a hyperlink as well as 2/5 (last two) shapes have their own hyperlinks. I’m unable to read those hyperlinks.
Kindly suggest.

Thanks,
Vineet

@vineet992

I think, your shape is Smart Art shape. We are afraid, Smart Art shapes are not supported at the moment.

When shape is a group shape, then you can get all the shapes using GroupShape.getGroupedShapes() method, it will return the array of all shapes inside the group shape.

Once, you get the shapes, you can access their hyperlinks with the code given to you in previous posts.

For Smart Art shapes, the issue has already been logged as

  • CELLSNET-40943 - Support SmartArt Shapes