Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Axlsx line break
require 'axlsx'
Axlsx::Package.new do |package|
workbook = package.workbook
workbook.add_worksheet do |sheet|
wrap = workbook.styles.add_style alignment: {wrap_text: true}
sheet.add_row ["Foo\r\nBar", "Foo\rBar", "Foo\nBar", "Foo\n\r\nBar"], style: wrap
end
package.serialize "linebreak.xlsx"
end
@NoSkillGuy
Copy link

NoSkillGuy commented Jun 14, 2016

The same code doesn't give a new line in my mac OSX. Then i added this line and it works
package.use_shared_string = true

@christianroy
Copy link

christianroy commented Aug 14, 2017

Re: Mac OSX, please note it's use_shared_strings (with an S at then end), not use_shared_string.

@quevon24
Copy link

quevon24 commented Jun 18, 2018

Thanks, works great in Excel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment