def merge_range(*args)
    # Check for a cell reference in A1 notation and substitute row and column
    args = row_col_notation(args)

    raise "Incorrect number of arguments" if args.size != 6 and args.size != 7
    raise "Format argument is not a format object" unless args[5].respond_to?(:xf_index)

    rwFirst  = args[0]
    colFirst = args[1]
    rwLast   = args[2]
    colLast  = args[3]
    string   = args[4]
    format   = args[5]
    encoding = args[6] ? 1 : 0

    merge_range_core(rwFirst, colFirst, rwLast, colLast, string, format, encoding) do |rwFirst, colFirst, string, format, encoding|
      if encoding != 0
        write_utf16be_string(rwFirst, colFirst, string, format)
      else
        write(rwFirst, colFirst, string, format)
      end
    end
  end
def merge_range(*args)
    # Check for a cell reference in A1 notation and substitute row and column
    args = row_col_notation(args)

    raise "Incorrect number of arguments" if args.size != 6 and args.size != 7
    raise "Format argument is not a format object" unless args[5].respond_to?(:xf_index)

    rwFirst  = args[0]
    colFirst = args[1]
    rwLast   = args[2]
    colLast  = args[3]
    string   = args[4]
    format   = args[5]
    encoding = args[6] ? 1 : 0

    merge_range_core(rwFirst, colFirst, rwLast, colLast, string, format, encoding) do |rwFirst, colFirst, string, format, encoding|
      if encoding != 0
        write_utf16be_string(rwFirst, colFirst, string, format)
      else
        write(rwFirst, colFirst, string, format)
      end
    end
  end
Older method name for backwards compatibility.
 *thaw_panes = *split_panes;

 :call-seq:
   merge_range(first_row, first_col, last_row, last_col, token, format, utf_16_be)

 This is a wrapper to ensure correct use of the merge_cells method, i.e.,
 write the first cell of the range, write the formatted blank cells in the
 range and then call the merge_cells record. Failing to do the steps in
 this order will cause Excel 97 to crash.

 Merging cells can be achieved by setting the merge property of a Format
 object, see "CELL FORMATTING". However, this only allows simple Excel5
 style horizontal merging which Excel refers to as "center across selection".


 The merge_range() method allows you to do Excel97+ style formatting where
 the cells can contain other types of alignment in addition to the merging:

     format = workbook.add_format(
                              :border  => 6,
                              :valign  => 'vcenter',
                              :align   => 'center'
                            )

     worksheet.merge_range('B3:D4', 'Vertical and horizontal', format)

 <em>WARNING.</em> The format object that is used with a merge_range()
 method call is marked internally as being associated with a merged range.
 It is a fatal error to use a merged format in a non-merged cell. Instead
 you should use separate formats for merged and non-merged cells. This
 restriction will be removed in a future release.

 The _utf_16_be_ parameter is optional, see below.

 merge_range() writes its _token_ argument using the worksheet write()
 method. Therefore it will handle numbers, strings, formulas or urls as
 required.

 Setting the merge property of the format isn't required when you are using
 merge_range(). In fact using it will exclude the use of any other horizontal
 alignment option.

 Your can specify UTF-16BE worksheet names using an additional optional
 parameter:

     str = [0x263a].pack('n')
     worksheet.merge_range('B3:D4', str, format, 1)   # Smiley

 The full possibilities of this method are shown in the merge3.rb to
 merge65.rb programs in the examples directory of the distribution.