Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application, both ASP.NET web sites and Windows Forms application.

Fri Jun 20, 2008 11:16 am

I got problems with adding a link (internal and external) to a worksheet.

Code: Select all
string testlink = "=HYPERLINK(\"http://www.whatever.com/\";\"LINK\")";
workbook.Worksheets[0].Range["A1"].Formula = testlink;


With this, the formula in Excel is shown this way:

=HYPERLINK("http://www.whatever.com/"";""LINK")

Because of the doubled " before and after the ';', Excel cannot use the link correctly (wrong reference). What to do to have this correctly?

EDIT:
If i display the link in a MessageBox it shows the string in the correct way:
=HYPERLINK("http://www.whatever.com/";"LINK")

pb
 
Posts: 14
Joined: Fri Jun 20, 2008 11:05 am

Mon Jun 23, 2008 8:51 am

I've updated to a newer version of Spire.XLS. Now the doubled " is no longer a problem, but now the ';' is marked as "UnexpectedToken".

FYI: after the ';' would be alias for the link.

This works:
Code: Select all
string testlink = "=HYPERLINK(\"http://www.whatever.com/\")";
workbook.Worksheets[0].Range["A1"].Formula = testlink;


This not:
Code: Select all
string testlink = "=HYPERLINK(\"http://www.whatever.com/\";\"LINK\")";
workbook.Worksheets[0].Range["A1"].Formula = testlink;


What to do now?

pb
 
Posts: 14
Joined: Fri Jun 20, 2008 11:05 am

Mon Jun 23, 2008 1:46 pm

Solved my problem by using the HyperLinks property.

Code: Select all
Workbook wb = new Workbook();

HyperLink link = workbook.Worksheets[0].HyperLinks.Add(workbook.Worksheets[0].Range["A1"];
link.Type = HyperLinkType.Url;
link.Address = "http://www.whatever.com";
link.TextToDisplay = "LINK";



It would be good if the other version would work as well, because for certain uses it would be easier to handle.

pb
 
Posts: 14
Joined: Fri Jun 20, 2008 11:05 am

Return to Spire.XLS