Prawn gem: How to create the .pdf from an *existing* file (.xls)

与世无争的帅哥 提交于 2019-12-04 06:06:19

问题


Can anybody show me (maybe copy/paste a simple code example) how to create the .pdf file from an existing (.xls) file, using the Prawn gem? (Basically, I'd need the command that "opens" the existing file.)

(I'm asking because the Prawn documentation (http://prawn.majesticseacreature.com/docs/) seems to be gone since quite a while - it's not even usable via Google cache...)

Thanks a lot for any help with this! Tom


回答1:


I'd suggest that you break the problem down.

  1. Can you read xls with Ruby? Possibly, but it's flaky at best. However, you can easily read csv, and xls exports nicely to that format.

  2. Can you write a 'table' of values to a prawn pdf? Yes

So, (almost) all you need is a little program that can parse a csv file into a prawn-friendly table-structure and then hand it off to Prawn for generation.




回答2:


Prawn can be used to render content on top of a PDF. You're talking about .xls, a completely different format.




回答3:


Turns out the Prawn gem cannot handle existing files...



来源:https://stackoverflow.com/questions/3148370/prawn-gem-how-to-create-the-pdf-from-an-existing-file-xls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!