We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding query params to a hyperlink in excel

Is it possible to add url parameters to a hyperlink in an excel workbook? For example: I want to create a hyperlink to `https://mysite.com/index.html?a=1&b=2` on my excel worksheet.

Thank you!


This message was posted using Page2Forum from Aspose products - Documentation

Hi,

Yes, you can add the url:

E.g.,

// Create a Workbook object
Workbook workbook = new Workbook();
// Obtain the reference of the first sheet
Worksheet worksheet = workbook.Worksheets[0];
// Add a hyperlink to A1 Cell.
int index = worksheet.Hyperlinks.Add("A1",1,1,"https://mysite.com/index.html?a=1&b=2");
// Create a Hyperlink object to fetch the existing hyperlink
Hyperlink hlink = worksheet.Hyperlinks[index];
// Set the label to display
hlink.TextToDisplay = "Link";
// Save the Excel file
workbook.Save(@"d:\test\linkages.xls");

Thank you.

Thanks for the quick response Amjad.

We have an application where we are using the Add function from the Aspose Hyperlink class to add a hyperlink to an Excel Report. However the link when clicked upon opens about.blank for a millisecond and then gets redirected to the login page of the website we want to open. On logging in the url loses the query parameters one of which is the tab information for the tab that should be opened.

However, when we paste the same link in a new browser window then the user is first directed to login and then to the correct tab (the url parameters are still available.)

Any suggestions / solutions would be much appreciated.

Thanks

Ritika

Hi Ritika,

Well, Aspose.Cells follows the MS Excel standards. I am not sure if this the behavior of MS Excel, but, could you insert a hyperlink in MS Excel manually using MS Excel menu options and check the results.

Thank you.