Search code examples
ruby-on-railsaxlsx

Rails Axlsx New Line in Cell


Is there a way that I can add a new line to a cell using the Axlsx gem in Rails?

So basically replicating in Excel once you enter a value you can do a Alt + Enter to add additional text to the new line in the cell. I tried

sheet.add_row ["Testing cell row 1" + \r\n + "Testing cell row 2"]

but that throws an error.


Solution

  • For a forced line feed use "\x0A" (breaks between paragraphs.)

    If you want both carriage return and line feed, use "\x0D\x0A".