Generate MS Word files in Rails

Hey all,

Can you suggest a good gem for generating word files from Rails. The
main
requirement is to replace some sections inside an existing template in
rails.

I used docx_replace, but found that it’s not always replacing the
variable
names with the template values.

Thanks,
Ganesh

On Mar 25, 2015, at 1:20 AM, Ganesh Ranganathan
[email protected] wrote:

Can you suggest a good gem for generating word files from Rails. The main
requirement is to replace some sections inside an existing template in rails.

  1. You might want to use RTF templates instead. It’s a format you can
    more easily search for your markers and modify, and Word will open it
    directly.

  2. If RTF is insufficient, you might consider Word + VBA, and use Word’s
    actual scripting to fill in the templates. (Perhaps also OpenOffice or a
    derivative.)

  3. Perhaps there’s something in the OpenOffice libraries which could be
    wrapped up into a gem to do what you want.

I used docx_replace, but found that it’s not always replacing the variable names
with the template values.

Note the second sentence in the description of docx_replace: “This is
purposefully meant to be simple and feature-light.”

The specification of the docx format is over 7,000 pages–“simple” and
“complete” are incompatible goals when dealing with docx.


Scott R.
[email protected]
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice

On Mar 26, 2015, at 2:11 AM, Ganesh Ranganathan
[email protected] wrote:

Does RTF pose any formatting challenges as compared to docx? Except bold,
italics, bulleting my requirement doesn’t need any advanced formatting.

In that case, RTF should be quite easy to deal with. There are two ways
to approach it, and I’d actually suggest doing both just to learn about
RTF. You can search for “RTF specification” and download it from
Microsoft. You can also create a document in Word, and save to RTF. The
first approach will tell you more about the minimal RTF you could use to
get that simple formatting. The second approach will show you everything
Word specifies, which is a lot. I’d bet that the RTF that specifies what
you really want to lies in between. (Of course, you might just use what
Word outputs and be done–who cares if it overspecifies document
attributes.)


Scott R.
[email protected]
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs