This project has moved and is read-only. For the latest updates, please go here.

Extract URL from formula

Oct 3, 2012 at 3:11 PM
Edited Oct 3, 2012 at 3: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(\"\")"

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

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

Oct 3, 2012 at 5:42 PM

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


Oct 3, 2012 at 5:46 PM

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

Oct 3, 2012 at 5:53 PM

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

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

Oct 3, 2012 at 6: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;