Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed May 23, 2018 5:34 pm

I'm creating a workbook with multiple worksheets. On the first worksheet I'm creating a "Table of Contents" that lists info about the following worksheets.

How do I use Spire.XLS to create a hyperlink that will take the user to another page in the same workbook? For example, if I have a cell on worksheet 0 where I want a hyperlink to take the user to worksheet 12, how do I do this? The examples I've seen for creating hyperlinks all were for linking to a separate web page.

Thanks for your help!

Kevin McElhiney
Palm Harbor, Florida, U.S.A.

kevinamac
 
Posts: 2
Joined: Wed May 23, 2018 5:06 pm

Thu May 24, 2018 3:05 am

Hello Kevin McElhiney,

Thanks for your post.
Our Spire.XLS supports the feature you need, please refer to the code below.
Code: Select all
var workbook = new Workbook();
workbook.LoadFromFile(path);
Worksheet sheet = workbook.Worksheets[0];

HyperLink UrlLink = sheet.HyperLinks.Add(sheet.Range["B2"]);
UrlLink.TextToDisplay = "Go to Sheet2 RangeB2";
//set the link type to be "Workbook"
UrlLink.Type = HyperLinkType.Workbook;
//setting the address, eg, sheet2 range b2
UrlLink.Address = "Sheet2!B2";

workbook.SaveToFile("ExcelHyperlink.xlsx", ExcelVersion.Version2010);


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Thu May 24, 2018 12:38 pm

Thank you very much! That is exactly what I needed. I appreciate the excellent support you provide for your products and I'm planning to use your libraries extensively in my future development!

kevinamac
 
Posts: 2
Joined: Wed May 23, 2018 5:06 pm

Fri May 25, 2018 1:34 am

Dear Kevin McElhiney,

Thank you for your valuable feedback.
Just feel free to contact us if you need assistance.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.XLS