def write_formula(*args)
      # Check for a cell reference in A1 notation and substitute row and column
      row, col, formula, format, value = row_col_notation(args)
      raise WriteXLSXInsufficientArgumentError if [row, col, formula].include?(nil)

      if formula =~ /^\{=.*\}$/
        write_array_formula(row, col, row, col, formula, format, value)
      else
        check_dimensions(row, col)
        store_row_col_max_min_values(row, col)
        formula = formula.sub(/^=/, '')

        store_data_to_table(FormulaCellData.new(self, row, col, formula, format, value))
      end
    end
def write_formula(*args)
      # Check for a cell reference in A1 notation and substitute row and column
      row, col, formula, format, value = row_col_notation(args)
      raise WriteXLSXInsufficientArgumentError if [row, col, formula].include?(nil)

      if formula =~ /^\{=.*\}$/
        write_array_formula(row, col, row, col, formula, format, value)
      else
        check_dimensions(row, col)
        store_row_col_max_min_values(row, col)
        formula = formula.sub(/^=/, '')

        store_data_to_table(FormulaCellData.new(self, row, col, formula, format, value))
      end
    end
:call-seq:
   write_formula(row, column, formula [ , format [ , value ] ] )

 Write a formula or function to the cell specified by +row+ and +column+:

     worksheet.write_formula(0, 0, '=$B$3 + B4')
     worksheet.write_formula(1, 0, '=SIN(PI()/4)')
     worksheet.write_formula(2, 0, '=SUM(B1:B5)')
     worksheet.write_formula('A4', '=IF(A3>1,"Yes", "No")')
     worksheet.write_formula('A5', '=AVERAGE(1, 2, 3, 4)')
     worksheet.write_formula('A6', '=DATEVALUE("1-Jan-2001")')

 Array formulas are also supported:

     worksheet.write_formula('A7', '{=SUM(A1:B1*A2:B2)}')

 See also the write_array_formula() method.

 See the note about {"Cell notation"}[#label-Cell+notation].
 For more information about writing Excel formulas see
 {"FORMULAS AND FUNCTIONS IN EXCEL"}[#label-FORMULAS+AND+FUNCTIONS+IN+EXCEL]

 If required, it is also possible to specify the calculated value
 of the formula. This is occasionally necessary when working with
 non-Excel applications that don't calculate the value of the
 formula. The calculated +value+ is added at the end of the argument list:

     worksheet.write('A1', '=2+2', format, 4)

 However, this probably isn't something that will ever need to do.
 If you do use this feature then do so with care.