[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Templates in Ruport class

Firstname Surname

2/20/2007 8:08:00 AM

Hello, all.


How can I use a templates in the ruport. Does the ruport class support
templates?



Thank you.

--
Posted via http://www.ruby-....

4 Answers

Chris Carter

2/20/2007 6:06:00 PM

0

On 2/20/07, Firstname Surname <pfocchken@yandex.ru> wrote:
> Hello, all.
>
>
> How can I use a templates in the ruport. Does the ruport class support
> templates?
>
>
>
> Thank you.
>
> --
> Posted via http://www.ruby-....
>
>

Hi Firstname,
Try the Ruport group:
http://groups.google.com/group/ru...


--
Chris Carter
concentrationstudios.com
brynmawrcs.com

Gregory Brown

2/20/2007 8:52:00 PM

0

On 2/20/07, Firstname Surname <pfocchken@yandex.ru> wrote:
> Hello, all.
>
>
> How can I use a templates in the ruport. Does the ruport class support
> templates?

You mean ERb templates? Yeah, we support them, though I've never had
any feature requests or suggestions about them so I tend to forget
they're even there. Here is a simple example

# foo.rb
require "ruport"

class MyReport < Ruport::Report

def generate
@html_table = [[1,2,3],[4,5,6]].to_table(%w[a b c]).to_html
erb "foo.rhtml"
end

end

puts MyReport.run

# foo.rhtml

<html>
<body>
<%= @html_table %>
</body>
</html>

--------------------------------------------------------

If you'd like to chat about this some more, the best place to do it is
the Ruport mailing list
( http://list.rubyr... ) [ which is just a different URI for
the same list Chris Carter linked ]

warm regards,
-greg

Firstname Surname

2/21/2007 10:27:00 AM

0

Gregory Brown wrote:
> On 2/20/07, Firstname Surname <pfocchken@yandex.ru> wrote:
>> Hello, all.
>>
>>
>> How can I use a templates in the ruport. Does the ruport class support
>> templates?
>
> You mean ERb templates? Yeah, we support them, though I've never had
> any feature requests or suggestions about them so I tend to forget
> they're even there. Here is a simple example
>

No, I mean, that if I have a query and I need to display data in
different formats(html, pdf, csv), can I describe data's view in some
file such as test.xml:

<?xml version="1.0"?>
<!DOCTYPE report >
<Report fontSize="9" orientation="landscape">
<ReportHeader>
<Output>
<Line/>
<Line fontSize="16">
<literal>Something:</literal>
</Line>
<Line/>
<Line fontSize="12">
<literal>Report's name</literal>
</Line>
<Line fontsize="4"/>
<HorizontalLine size="4" bgcolor="'white'"/>
<HorizontalLine size="2" bgcolor="'black'"/>
<HorizontalLine size="4" bgcolor="'white'"/>
</Output>
</ReportHeader>
.....................
.....................

or in yaml format, and after this when I generate my report in all
formats, I will have data good looking.

Now, when I execute code somthing like this:

class MyRuport < Ruport::Report
include DogTag

attr_accessor :main_query
attr_accessor :parameters
attr_accessor :output_format

prepare do

generate do

query(main_query, {:as => output_format.to_sym})
end

end

ruport = MyReport.new
ruport.main_query = "select * from test_table"
ruport.output_format = "html"

ruport.run{ |res| puts res.results }

I have results:
<table>
<tr>
<th>id</th>
<th>test</th>
</tr>
</table>

O something like this in pdf...

Can I put into my project some template file that will give outout data
looks better? And how can I do this with ruport. And have the ruport
some standart ways to solve this problem.


Thank you for answers. Artem Lakin.




--
Posted via http://www.ruby-....

Gregory Brown

2/21/2007 3:06:00 PM

0

On 2/21/07, Artem Lakin <pfocchken@yandex.ru> wrote:

> No, I mean, that if I have a query and I need to display data in
> different formats(html, pdf, csv), can I describe data's view in some
> file such as test.xml:

No. But let's talk about this over on the Ruport list. Sounds like a
great idea for a plugin.

Those following along can find the thread here:

http://tinyurl....

I'll give a detailed reply there.