Home » excel » ruby – How do I build an XML file?

ruby – How do I build an XML file?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m building up an XML template to export to Excel.

I would like to do something like this:

<Worksheet ss:Name=<%= page.title %>>

to give the worksheet the name of the page title but this does not work.

If I do:

<Worksheet ss:Name="sheet1">

it all works.

How can I assign the page title to the worksheet name?

How to&Answers:

The problem is likely that you’re not wrapping page.title in quotes, so Excel can’t properly parse the file. You should add them just outside the erb code:

<Worksheet ss:Name="<%= page.title %>">