Helpful Information
 
 
Category: Ruby Programming
ROR and Crystal Report Viewer?

I have written an application in ROR, and have now come to the reporting piece. Reports will be written in Crystal and I'm wondering if ROR will allow me to utilize the Crystal Reports Viewer. Has anyone had any experience with this? Any opinions or advice always appreciated!

Thank you!

Crystal reports can be configured to read XML input and format it accordingly. Hence, you can use a rails handler to output your report data in XML format and that should allow crystal reports to read from it.

Crystal reports can be configured to read XML input and format it accordingly. Hence, you can use a rails handler to output your report data in XML format and that should allow crystal reports to read from it.

My reports use xml schemas (xsd) and they get fed at runtime using .net dataset. I know this is possible in .net but how is it possible in ROR? How is the xml data fed to these reports in Ruby. Plus what about the report viewer?

sumeet chadddha

If you're using RoR, the part that gets the data should be a method in the model/ directory. For instance:


class MyData < ActiveRecord::Base
def self.getmydata(key)
find(:all, :conditions => ["field1 = ?", key])
end
end


Then, your controller class would look something like this:


class mycontroller < ActionController
def xml_output
id = params[:id]
@data = MyData.getmydata(id)
end
end


and your view template for xml_output.rhtml could look something like this:


<data>
<% for item in @data %>
<item>
<id><%= item.id %></id>
<name><%= h(item.name) %></name>
<desc><%= h(item.desc) %></desc>
</item>
<% end %>
</data>










privacy (GDPR)