This project has moved. For the latest updates, please go here.

Extract URL from formula

Oct 3, 2012 at 2:11 PM
Edited Oct 3, 2012 at 2:13 PM

What is the best way to extract URL from Hyperlink formula?

Now I'm using Value.ToString()

string url = worksheet.Cell(i, 2).Value.ToString();
// url == "HYPERLINK(\"http://google.com\")"

And then deleting HYPERLINK(\" and \") via url.Replace();

But I think there is more nice approach to do that.

Coordinator
Oct 3, 2012 at 4:42 PM

If the cell has a hyperlink then you can just use:

cell.Hyperlink.ExternalAddress

Oct 3, 2012 at 4:46 PM

I've tried it... It is null.

Coordinator
Oct 3, 2012 at 4:53 PM

Create an issue and attach the file so I can see what you have...

Oct 3, 2012 at 5:01 PM
Edited Oct 3, 2012 at 5:01 PM

https://dl.dropbox.com/u/17976179/hyperlink.xlsm

Coordinator
Oct 3, 2012 at 5:24 PM

You're in luck that I'm in the middle of implementing formulas. Pick up the latest source code and use:

            var h = ws.Cell("B1").Value as XLHyperlink;