Free Support Forum - aspose.com

Adding sub-address to a hyperlink


#1

Hi,

I have a piece of VBA code which I am trying to re-write in JAVA using Aspose cells. I have attached the code snippet for reference. The code is being used to insert hyperlinks in a worksheet based on certain conditions. In one of such conditions, I am required to add a sub-address field to a hyperlink. I could not find such a functionality in Aspose cells although there was some reference to it in the thread mentioned below,

Could you please look into it ?

Code snippet:

 With worksheet.Hyperlinks
    If(Condition 1)
                    If (Condition 2) Then
                        .Add Anchor:=range, Address:="Some URL"
                    Else
                        .Add Anchor:=range, Address:="Some URL"
                         ScreenTip:=Screen_tip
                    End If
    ElseIf (Condition 3)Then
                    If (Condition 4) Then
                        .Add Anchor:=range, Address:="", SubAddress:=link_Location
                    Else
                        .Add Anchor:=range, Address:="", SubAddress:=link_Location, ScreenTip:=Screen_tip
                    End If
     End If

The equivalent JAVA code I am looking for should look something like,

if(condition 1)
    if(condition 2)
        worksheet.getHyperlinks().add(startCell, totalRows, totalColumns, address)
    else
        worksheet.getHyperlinks().add(startCell, endCell, address, textToDisplay, screenTip)
else if(condition 3)
     if(condition 4)
        worksheet.getHyperlinks().add(startCell, totalRows,totalColumns, "", subAddress)
     else
        worksheet.getHyperlinks().add(startCell, endCell, "", subAddress, screenTip)

#2

@jinesh.parikhmca1983,

Thanks for the details.

Please see the document on how you can add different types of hyperlinks to link data via Aspose.Cells APIs:
https://docs.aspose.com/display/cellsjava/Working+with+Hyperlinks+to+Link+Data

I am not sure about adding a sub-address field to a hyperlink. Could you provide details and steps involved on how to do it in MS Excel manually (and not by VBA code). If MS Excel supports this feature, Aspose.Cells should support it. And, we can look into it as well.


#3

Hi,

Thanks for the prompt reply. The link you sent resolves my problem. I was not aware that the add hyperlink method accepts a range reference (which is called a sub-address in Excel) as the hyperlink address. In this case, your API already has support for sub-addresses.

Thanks


#4

@jinesh.parikhmca1983,

Good to know that your issue is sorted out by the suggested link. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.