Q:

Rails axlsx gem - Formula not escaping

Is there a way to ignore executing a formula while rendering spreadsheet?
Currently, sheet.add_row("=10+10") will evaluate 20, even if I give :formula => :false or :type=> :string
The only hacky way is to provide a single quote, but it's not a pretty approach.

A:

I looked at the source code of the gem in question, the following code is there:
def is_formula?
   @type == :string && @value.to_s.start_with?('=')
end

It means that anything of type string with '=' will be treated like a formula.  And the only accepted types are date, string, integer, float etc.  Anything else in place of :type => :string and it does not accept it.  
As an alternative, I had to open the class cell_serializer.rb in the gem and reimplement the method in a custom way to get rid of cell.is_formula? check. 
def string_type_serialization(cell, str='')
      if cell.is_formula?
        formula_serialization cell, str
      elsif !cell.ssti.nil?
        value_serialization 's', cell.ssti.to_s, str
      else
        inline_string_serialization cell, str
      end
 end

Reimplemented method:
def string_type_serialization(cell, str='')
        if !cell.ssti.nil?
          value_serialization 's', cell.ssti.to_s, str
        else
          inline_string_serialization cell, str
        end
end

I realize it's a hacky way, but it affects system wide code.  If I need anything complex in future, I can always make changes to one central place.

