def write_url_internal(row1, col1, row2, col2, url, str = nil, format = nil)       #:nodoc:
    record = 0x01B8                       # Record identifier
    length = 0x00000                      # Bytes to follow

    xf     = format || url_format        # The cell format

    # Strip URL type
    url = url.sub(/^internal:/, '')

    # Write the visible label but protect against url recursion in write().
    str          = url.dup unless str
    error        = write_string(row1, col1, str, xf)
    return error if error == -2

    # Pack the undocumented parts of the hyperlink stream
    unknown1    = ["D0C9EA79F9BACE118C8200AA004BA90B02000000"].pack("H*")

    # Pack the option flags
    options     = [0x08].pack("V")

    # URL encoding.
    encoding    = 0

    # Convert an Utf8 URL type and to a null terminated wchar string.
    ruby_18 do
      if is_utf8?(url)
        # Quote sheet name if not already, i.e., Sheet!A1 to 'Sheet!A1'.
        url = "'#{sheetname_from_url(url)}'!#{cell_from_url(url)}" if not url =~ /^'/
        # URL is null terminated.
        ruby_18 { url = utf8_to_16be(url) + "\0\0" } ||
          encoding = 1
      end
    end

    # Convert an Ascii URL type and to a null terminated wchar string.
    if encoding == 0
      url += "\0"
      url = url.unpack('c*').pack('v*')
    end

    # Pack the length of the URL as chars (not wchars)
    url_len     = [(url.bytesize/2).to_i].pack("V")

    # Calculate the data length
    length         = 0x24 + url.bytesize

    # Pack the header data
    header      = [record, length].pack("vv")
    data        = [row1, row2, col1, col2].pack("vvvv")

    # Write the packed data
    append( header, data, unknown1, options, url_len, url)

    error
  end
def write_url_internal(row1, col1, row2, col2, url, str = nil, format = nil)       #:nodoc:
    record = 0x01B8                       # Record identifier
    length = 0x00000                      # Bytes to follow

    xf     = format || url_format        # The cell format

    # Strip URL type
    url = url.sub(/^internal:/, '')

    # Write the visible label but protect against url recursion in write().
    str          = url.dup unless str
    error        = write_string(row1, col1, str, xf)
    return error if error == -2

    # Pack the undocumented parts of the hyperlink stream
    unknown1    = ["D0C9EA79F9BACE118C8200AA004BA90B02000000"].pack("H*")

    # Pack the option flags
    options     = [0x08].pack("V")

    # URL encoding.
    encoding    = 0

    # Convert an Utf8 URL type and to a null terminated wchar string.
    ruby_18 do
      if is_utf8?(url)
        # Quote sheet name if not already, i.e., Sheet!A1 to 'Sheet!A1'.
        url = "'#{sheetname_from_url(url)}'!#{cell_from_url(url)}" if not url =~ /^'/
        # URL is null terminated.
        ruby_18 { url = utf8_to_16be(url) + "\0\0" } ||
          encoding = 1
      end
    end

    # Convert an Ascii URL type and to a null terminated wchar string.
    if encoding == 0
      url += "\0"
      url = url.unpack('c*').pack('v*')
    end

    # Pack the length of the URL as chars (not wchars)
    url_len     = [(url.bytesize/2).to_i].pack("V")

    # Calculate the data length
    length         = 0x24 + url.bytesize

    # Pack the header data
    header      = [record, length].pack("vv")
    data        = [row1, row2, col1, col2].pack("vvvv")

    # Write the packed data
    append( header, data, unknown1, options, url_len, url)

    error
  end
row1                         # Start row
    col1                         # Start column
    row2                         # End row
    col2                         # End column
    url                          # URL string
    str                          # Alternative label

 Used to write internal reference hyperlinks such as "Sheet1!A1".

 See also write_url() above for a general description and return values.