Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Managed to create a document by clicking on save button but...
One of the fields in Excel contains path to a file. It is correct as string, but Ito me it will be better if is was a link to file and actually opened file on click.

Is it possible to do from C#?

Here how it look (as example to explain what do Ihave right now, i understand that my english is near to trash level):

Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
excel.Workbooks.Add();

Microsoft.Office.Interop.Excel._Worksheet workSheet = excel.ActiveSheet;

...

workSheet.Cells[row, "A"] = item.ActionType;
workSheet.Cells[row, "B"] = "sek: " + item.AfterClick.Seconds.ToString() + " msek: " + item.AfterClick.Milliseconds.ToString();
workSheet.Cells[row, "C"] = item.Time.ToLongTimeString();
workSheet.Cells[row, "D"] = "pic" + item.id.ToString();
workSheet.Cells[row, "E"] = string.Format(@"{0}\{1}\Pictures\pic{2}.jpeg", path, folder, item.id);


As you can see, the data on "E" should bve link to file instead of simple text.
Posted
Comments
Maciej Los 9-May-14 13:09pm    
Post it as an answer. My virtual 5!
ZurdoDev 9-May-14 13:04pm    
Record a macro in Excel doing what you want and then you can see what the code would be.

 
Share this answer
 
Comments
Maciej Los 10-May-14 8:57am    
Real 5!
workSheet.Cells[row, "E"] = string.Format(@"=Hyperlink({0}\{1}\Pictures\pic{2}.jpeg)", path, folder, item.id);
 
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