If anyone can help me, i would like a button that converts html view(mostly reports with tables) into a document that can open in msword or openoffice where i can edit it later. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
There is an RTF writer for Ruby. YOu would have to program it yourself, but it looks fairly easy. Regards Mikel On Jul 1, 3:03 pm, Alias <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> If anyone can help me, i would like a button that converts html > view(mostly reports with tables) into a document that can open in msword > or openoffice where i can edit it later. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn
2007-Jul-02 15:02 UTC
Re: Save as document that can open in msword or openoffice
You can give a URL to the MS-Word open prompt (never tried it with OO, but might work, too). You can also change the content-type of the page (on the server) and the browser will hand it off to another application. Content-type:application/vnd.ms-excel (since you said tables, I''m thinking it''s spreadsheet-like data) -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org On Jul 1, 2007, at 4:28 AM, Mikel wrote:> There is an RTF writer for Ruby. YOu would have to program it > yourself, but it looks fairly easy. > > Regards > > Mikel > > On Jul 1, 3:03 pm, Alias <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> If anyone can help me, i would like a button that converts html >> view(mostly reports with tables) into a document that can open in >> msword >> or openoffice where i can edit it later. >> >> ----~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Vasudev Ram
2007-Jul-03 16:37 UTC
Re: Save as document that can open in msword or openoffice
Alias wrote:>If anyone can help me, i would like a button that converts htmlview(mostly reports with tables) into a document that can open in msword or openoffice where i can edit it later. Yes, generating RTF is not difficult. I''ve not used the Ruby RTF library, but I have used PyRTF which is for Python, and have rolled my Java own code for RTF generation in a J2EE app. I looked at the RTF spec and worked out what to write. Basically, RTF is a rich text format that can be opened in MS Word or OpenOffice.org. It uses hierarchical tags ( braces: "{" and "}" ) - with markup, like HTML does, to say how the text should be displayed, e.g. headings, fonts, tables, etc. Here''s what you can try: In the view I assume you''ll have some form(s) to accept some parameters used to generate the report, e.g. order_no between 100 and 200, etc. Apart from generating the HTML report views based on this input, write other methods in your controllers (or write another controller, as appropriate), which in turn call methods of a model class. This class can call the Ruby RTF library to generate the report as an RTF file, and pass the filename back to the controller (or the controller can specify the filename as an argument to the model method); some path on the filesystem will have to be decided, where the file(s) generated will be stored - you can use RAILS_ROOT as the prefix for this. The controller can then either send the file to the browser using send_file or send_data (including setting the Content-type, Content-length and Disposition HTTP headers appropriately). Vasudev Ram Dancing Bison Enterprises http://www.dancingbison.com http://jugad.livejournal.com http://sourceforge.net/projects/xtopdf -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Vasudev Ram
2007-Jul-03 16:45 UTC
Re: Save as document that can open in msword or openoffice
Vasudev Ram wrote:> > > Alias wrote: >>If anyone can help me, i would like a button that converts html > view(mostly reports with tables) into a document that can open in msword > or openoffice where i can edit it later. > > Yes, generating RTF is not difficult. I''ve not used the Ruby RTF > library, but I have used PyRTF which is for Python, and have rolled my > Java own code for RTF generation in a J2EE app. I looked at the RTF spec > and worked out what to write. > Basically, RTF is a rich text format that can be opened in MS Word or > OpenOffice.org. It uses hierarchical tags ( braces: "{" and "}" ) - with > markup, like HTML does, to say how the text should be displayed, e.g. > headings, fonts, tables, etc. > > Here''s what you can try: > > In the view I assume you''ll have some form(s) to accept some parameters > used to generate the report, e.g. order_no between 100 and 200, etc. > Apart from generating the HTML report views based on this input, write > other methods in your controllers (or write another controller, as > appropriate), which in turn call methods of a model class that acts as a ''manager'' or ''helper'' class. This class > can call the Ruby RTF library to generate the report as an RTF file and > pass the filename back to the controller (or the controller can specify > the filename as an argument to the model method); some path on the > filesystem will have to be decided, where the file(s) generated will be > stored - you can use RAILS_ROOT as the prefix for this. The controller > can then either send the file to the browser using send_file or > send_data (including setting the Content-type, Content-length and > Disposition HTTP headers appropriately). > > Vasudev Ram > Dancing Bison Enterprises > http://www.dancingbison.com > http://jugad.livejournal.com > http://sourceforge.net/projects/xtopdfP.S.: In the previous post, insert the words " (after calling the appropriate other model classes to get the needed data from the DB), " after "generate the report as an RTF file". Note: Its not a requirement to have an underlying database table for each model class in Rails. I''ve seen that some people have this misunderstanding, so mentioning it. A model class is just a Ruby class, and can represent any concept or business logic; typical uses are for ''manager'' or ''helper'' classes that do something and also talk to the other table-backed models to do their work, like getting and setting table data. That''s the pattern I''ve used in my post above. - Vasudev -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---