def write(*args)
      # Check for a cell reference in A1 notation and substitute row and column
      row_col_args = row_col_notation(args)
      token = row_col_args[2] || ''

      # Match an array ref.
      if token.respond_to?(:to_ary)
        write_row(*args)
      elsif token.respond_to?(:coerce)  # Numeric
        write_number(*args)
      elsif token =~ /^\d+$/
        write_number(*args)
      # Match formula
      elsif token =~ /^=/
        write_formula(*args)
      # Match array formula
      elsif token =~ /^\{=.*\}$/
        write_formula(*args)
      # Match blank
      elsif token == ''
        row_col_args.delete_at(2)     # remove the empty string from the parameter list
        write_blank(*row_col_args)
      elsif @workbook.strings_to_urls
        # Match http, https or ftp URL
        if token =~ %r|\A[fh]tt?ps?://|
          write_url(*args)
        # Match mailto:
        elsif token =~ %r|\Amailto:|
          write_url(*args)
        # Match internal or external sheet link
        elsif token =~ %r!\A(?:in|ex)ternal:!
          write_url(*args)
        else
          write_string(*args)
        end
      else
        write_string(*args)
      end
    end
def write(*args)
      # Check for a cell reference in A1 notation and substitute row and column
      row_col_args = row_col_notation(args)
      token = row_col_args[2] || ''

      # Match an array ref.
      if token.respond_to?(:to_ary)
        write_row(*args)
      elsif token.respond_to?(:coerce)  # Numeric
        write_number(*args)
      elsif token =~ /^\d+$/
        write_number(*args)
      # Match formula
      elsif token =~ /^=/
        write_formula(*args)
      # Match array formula
      elsif token =~ /^\{=.*\}$/
        write_formula(*args)
      # Match blank
      elsif token == ''
        row_col_args.delete_at(2)     # remove the empty string from the parameter list
        write_blank(*row_col_args)
      elsif @workbook.strings_to_urls
        # Match http, https or ftp URL
        if token =~ %r|\A[fh]tt?ps?://|
          write_url(*args)
        # Match mailto:
        elsif token =~ %r|\Amailto:|
          write_url(*args)
        # Match internal or external sheet link
        elsif token =~ %r!\A(?:in|ex)ternal:!
          write_url(*args)
        else
          write_string(*args)
        end
      else
        write_string(*args)
      end
    end
:call-seq:
  write(row, column [ , token [ , format ] ])

 Excel makes a distinction between data types such as strings, numbers,
 blanks, formulas and hyperlinks. To simplify the process of writing
 data the {#write()}[#method-i-write] method acts as a general alias for several more
 specific methods:

     write_string
     write_number
     write_blank
     write_formula
     write_url
     write_row
     write_col

 The general rule is that if the data looks like a _something_ then
 a _something_ is written. Here are some examples in both row-column
 and A1 notation:

                                                     # Same as:
     worksheet.write(0, 0, 'Hello'                ) # write_string()
     worksheet.write(1, 0, 'One'                  ) # write_string()
     worksheet.write(2, 0,  2                     ) # write_number()
     worksheet.write(3, 0,  3.00001               ) # write_number()
     worksheet.write(4, 0,  ""                    ) # write_blank()
     worksheet.write(5, 0,  ''                    ) # write_blank()
     worksheet.write(6, 0,  nil                   ) # write_blank()
     worksheet.write(7, 0                         ) # write_blank()
     worksheet.write(8, 0,  'http://www.ruby.com/') # write_url()
     worksheet.write('A9',  'ftp://ftp.ruby.org/' ) # write_url()
     worksheet.write('A10', 'internal:Sheet1!A1'  ) # write_url()
     worksheet.write('A11', 'external:c:\foo.xlsx') # write_url()
     worksheet.write('A12', '=A3 + 3*A4'          ) # write_formula()
     worksheet.write('A13', '=SIN(PI()/4)'        ) # write_formula()
     worksheet.write('A14', [1, 2]                ) # write_row()
     worksheet.write('A15', [ [1, 2] ]            ) # write_col()

     # Write an array formula. Not available in writeexcel gem.
     worksheet.write('A16', '{=SUM(A1:B1*A2:B2)}' ) # write_formula()

 The +format+ parameter is optional. It should be a valid Format object,
 See {"CELL FORMATTING"}[Format.html#label-CELL+FORMATTING]:

     format = workbook.add_format
     format.set_bold
     format.set_color('red')
     format.set_align('center')

     worksheet.write(4, 0, 'Hello', format)    # Formatted string

 The {#write()}[#method-i-write] method will ignore empty strings or +nil+ tokens unless a
 format is also supplied. As such you needn't worry about special handling
 for empty or nil in your data. See also the write_blank() method.

 One problem with the {#write()}[#method-i-write] method is that occasionally data looks like
 a number but you don't want it treated as a number. For example, zip
 codes or ID numbers often start with a leading zero.
 If you want to write this data with leading zero(s), use write_string.

 The write methods return:
     0 for success.