0

My DB stores text from a WYSIWYG editor that looks something like this:

<p><s>Hi!</s></p> 
<p>My Name is Bob's.</p> 
<p> </p> 
<p>I like to eat these things:</p> 
<ul> 
 <li>Candy</li> 
 <li>Veggies</li> 
 <li>Everything</li> 
</ul>
<p>Enjoy<sup>2</sup></p>

In my view I have something like:

  sheet.add_row [@event.text], style: font_format

where @event.text is the above html

Is there a way to make this formatting work in excel using axlsx?

JS noob
  • 429
  • 5
  • 14

2 Answers2

0

I don't think there is any automatic conversion of html to styles. You'd have to write one yourself. I would use the rich text example as a guide.

I believe it handles any normal Axlsx style on a chunk of text. It at least handles bold, italic, and strikethrough.

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

But, that means you'll have to parse the html.

noel
  • 2,095
  • 14
  • 14
0

Yes, to_spreadsheet is just for you. I have just finish a Rails app using it to generate xlsx file for download. I just follow the instruction and create a view 'show.xlsx.erb' in view directory. And it's done!