Rails 4, replacing "\n" with " " for use in XML spreadsheets in excel



I'm writing an application that exports certain data into a specifically formatted Excel document. I'm building an XML spreadsheet file using this document (http://ift.tt/1tuMTXP)


and so far have it all working. BUT to get it working I had to use ".html_safe" in several fields which is dangerous in this instance as some of the fields being exported contain user entered data.


Basically to get a new line inside an excel cell you use "
" instead of the usual \n


I'm currently using:



t.business_impact.gsub("\n","
").html_safe


but is there a better way to do this that wont "html_safe" the entire string?


No comments:

Post a Comment