Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I am Export a data from datatable to Excel by sheet-wise using C#.In my first sheet have a all sheet name's in one column.
My question is how to set a link in first sheet values.If i click any value in first sheet it goes to that sheet.Please any one help to me with code using C#.

Advance Thanks,
T.Saravanan
Posted
Updated 11-Aug-10 1:17am
v2

Hi,

I am also got an answer.

objRange=objSheet.get_Range("A1","A3");
objSheet.Hyperlinks.Add(objRange,"","Sheet2!A1","",objSheet.Name);



Add this coding in Excel Export Method.

objSheet --> Sheet Object
objRange --> Range Object

Thanks & Regards,
T.Saravanan ;)
 
Share this answer
 
Record a macro while doing that. Then convert that to c# code.

I recorded it. Looks quite simple.

SQL
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="Sheet3!A1", TextToDisplay:="abc"


If you're using anything less than C# 4.0 you'll have to provide the default Type.Missing for all the expected params that are not of any use to you. One sunch param is the Address and I'm sure there are others. I'm talking about the ActiveSheet.Hyperlinks.Add method, when using Interop.
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900