'Write a hyperlink to a worksheet cell.
Args:
row:    The cell row (zero indexed).
col:    The cell column (zero indexed).
url:    Hyperlink url.
format: An optional cell Format object.
string: An optional display string for the hyperlink.
tip:    An optional tooltip.
Returns:
0:  Success.
-1: Row or column is out of worksheet bounds.
-2: String longer than 32767 characters.
-3: URL longer than Excel limit of 255 characters
-4: Exceeds Excel limit of 65,530 urls per worksheet'

@convert_cell_args
def write_url(self, row, col, url, cell_format=None, string=None, tip=None):

    if (string is None):
        string = url
    link_type = 1
    if re.match('internal:', url):
        url = url.replace('internal:', '')
        string = string.replace('internal:', '')
        link_type = 2
    external = False
    if re.match('external:', url):
        url = url.replace('external:', '')
        url = url.replace('/', '\\')
        string = string.replace('external:', '')
        string = string.replace('/', '\\')
        external = True
    string = string.replace('mailto:', '')
    if self._check_dimensions(row, col):
        return (-1)
    str_error = 0
    if (len(string) > self.xls_strmax):
        warn("Ignoring    URL    since    it    exceeds    Excel's    string    limit    of    32767    characters")
        return (-2)
    url_str = string
    if (link_type == 1):
        if ('#' in url):
            (url, url_str) = url.split('#', 1)
        else:
            url_str = None
        url = self._escape_url(url)
        if ((url_str is not None) and (not external)):
            url_str = self._escape_url(url_str)
        if (re.match('\\w:', url) or re.match('\\\\', url)):
            url = ('file:///' + url)
        url = re.sub('^\\.\\\\', '', url)
    tmp_url_str = (url_str or '')
    if ((len(url) > 255) or (len(tmp_url_str) > 255)):
        warn(("Ignoring    URL    '%s'    with    link    or    location/anchor    >    255    characters    since    it    exceeds    Excel's    limit    for    URLS" % force_unicode(url)))
        return (-3)
    self.hlink_count += 1
    if (self.hlink_count > 65530):
        warn(("Ignoring    URL    '%s'    since    it    exceeds    Excel's    limit    of    65,530    URLS    per    worksheet." % force_unicode(url)))
        return (-5)
    if (self.constant_memory and (row > self.previous_row)):
        self._write_single_row(row)
    if (cell_format is None):
        cell_format = self.default_url_format
    self.write_string(row, col, string, cell_format)
    self.hyperlinks[row][col] = {'link_type': link_type, 'url': url, 'str': url_str, 'tip': tip}
    return str_error
