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.

Mon Jun 03, 2019 3:46 am

I want to add a hyperlink to a picture in a workbook, and the hyperlink address is in the another worksheet of this workbook. How can i do this?
Thanks for your help!
Meng

Meng0527
 
Posts: 11
Joined: Mon Jun 03, 2019 3:30 am

Mon Jun 03, 2019 8:39 am

Hi,

Thanks for your inquiry.
Please refer to the following code to add a hyperlink for picture. If there is any question, please feel free to write back.
Code: Select all
            Workbook wb = new Workbook();
            wb.LoadFromFile("Input.xlsx");
            Worksheet sheet = wb.Worksheets[0];
            Worksheet sheet1 = wb.Worksheets[1];
            String url = sheet1.Range["A1"].Text;
            sheet.Pictures[0].SetHyperLink(url, true);
            wb.SaveToFile("Result.xlsx", ExcelVersion.Version2013);
            System.Diagnostics.Process.Start("Result.xlsx");

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Mon Jun 03, 2019 1:31 pm

thank u very much, your reply is exactly what i wanted. However,when I opened the workbook and click the picture, a message -- 'can not open the specified file' showed , and i am sure the hyperlink address is correct.Can you help me with this question?

Meng0527
 
Posts: 11
Joined: Mon Jun 03, 2019 3:30 am

Tue Jun 04, 2019 10:10 am

Hi,

Thanks for your feedback.
I looked back again for your previous description, and re-understood that your requirement is to add a hyperlink that refers to the range in another worksheet, am I right? If so, please use the code below to achieve it. Just feel free to write back if there is any question.
Code: Select all
            Workbook wb = new Workbook();
            wb.LoadFromFile("Input.xlsx");
            Worksheet sheet = wb.Worksheets[0];
            Worksheet sheet1 = wb.Worksheets[1];
            sheet.Pictures[0].SetHyperLink("#Sheet2!A1", false);
            wb.SaveToFile("Result.xlsx", ExcelVersion.Version2013);

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Tue Jun 04, 2019 2:15 pm

Thank u for your help, and my problem has been solved.

Sincerely!

Meng0527
 
Posts: 11
Joined: Mon Jun 03, 2019 3:30 am

Wed Jun 05, 2019 1:22 am

Hi,

Thanks for your feedback.
If there is anything we can do for you in the future, please do not hesitate to contact us.
Wish you all the best!

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Wed Jun 05, 2019 6:32 am

When i want to modify a hyperlink(not a picture hyperlink) as following, but when i open the excel and click the hyperlink, it says "invalid reference":
Code: Select all
HyperLinksCollection links = dest_worksheet.HyperLinks;
links[0].SetAddress("#Issue summary!C14", false);
Last edited by Meng0527 on Wed Jun 05, 2019 8:42 am, edited 1 time in total.

Meng0527
 
Posts: 11
Joined: Mon Jun 03, 2019 3:30 am

Wed Jun 05, 2019 7:05 am

Hello,

Thanks for your feedback.
After an initial test, I didn't reproduce your issue, the hyperlink address could be modified successfully on my side. To help us further look into it, please provide your testing Excel file. You could send it via email (support@e-iceblue.com).

Sincerely,
Lisa
E-iceblue support team
Last edited by Lisa.Li on Wed Jun 05, 2019 8:59 am, edited 1 time in total.
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Wed Jun 05, 2019 8:54 am

I have already sent an email to the mailbox.
Thanks

Meng0527
 
Posts: 11
Joined: Mon Jun 03, 2019 3:30 am

Wed Jun 05, 2019 9:09 am

Hello,

Sorry that I didn't get your email, please help to check on your side or you could send it to (lisa.li@e-iceblue.com) directly. Thanks in advance.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Wed Jun 05, 2019 11:34 am

I sent an email to you just now

Meng0527
 
Posts: 11
Joined: Mon Jun 03, 2019 3:30 am

Thu Jun 06, 2019 3:06 am

Hello,

Thank you for sharing your sample file via email.
Since the first sheet name “Issue summary” of your file contains a space, based on the internal mechanism of MS Excel itself, the sheet name will be added ‘’ automatically when referencing and it will be “ ‘Issue summary’ “. Thus, you have to replace "#Issue summary!C14" with "#'Issue summary'!C14" to get rid of your issue. If there is any question, just feel free to write back.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.XLS