def pack_ext_ref(ext_ref)
    ext_ref.sub!(/^'/,'')   # Remove leading  ' if any.
    ext_ref.sub!(/'$/,'')   # Remove trailing ' if any.

    # Check if there is a sheet range eg., Sheet1:Sheet2.
    if (ext_ref =~ /:/)
      sheet1, sheet2 = ext_ref.split(':')

      sheet1 = get_sheet_index(sheet1)
      sheet2 = get_sheet_index(sheet2)

      # Reverse max and min sheet numbers if necessary
      if (sheet1 > sheet2)
        sheet1, sheet2 = [sheet2, sheet1]
      end
    else
      # Single sheet name only.
      sheet1, sheet2 = [ext_ref, ext_ref]

      sheet1 = get_sheet_index(sheet1)
      sheet2 = sheet1
    end

    key = "#{sheet1}:#{sheet2}"

    if @ext_refs[key].nil?
      index = get_ext_ref_count
      @ext_refs[key] = index
      @ext_ref_count += 1
    else
      index = @ext_refs[key]
    end

    [index].pack("v")
  end
def pack_ext_ref(ext_ref)
    ext_ref.sub!(/^'/,'')   # Remove leading  ' if any.
    ext_ref.sub!(/'$/,'')   # Remove trailing ' if any.

    # Check if there is a sheet range eg., Sheet1:Sheet2.
    if (ext_ref =~ /:/)
      sheet1, sheet2 = ext_ref.split(':')

      sheet1 = get_sheet_index(sheet1)
      sheet2 = get_sheet_index(sheet2)

      # Reverse max and min sheet numbers if necessary
      if (sheet1 > sheet2)
        sheet1, sheet2 = [sheet2, sheet1]
      end
    else
      # Single sheet name only.
      sheet1, sheet2 = [ext_ref, ext_ref]

      sheet1 = get_sheet_index(sheet1)
      sheet2 = sheet1
    end

    key = "#{sheet1}:#{sheet2}"

    if @ext_refs[key].nil?
      index = get_ext_ref_count
      @ext_refs[key] = index
      @ext_ref_count += 1
    else
      index = @ext_refs[key]
    end

    [index].pack("v")
  end
Convert the sheet name part of an external reference, for example "Sheet1" or
 "Sheet1:Sheet2", to a packed structure.