Skip to content

Ruby Generate Reports

majorsilence edited this page Nov 22, 2014 · 3 revisions

Currently the RdlCmd ruby wrapper code is not bundled in a release. You must download a copy from master. To view online go to https://github.com/majorsilence/My-FyiReporting/tree/master/LanguageWrappers/ruby. Examples of using python is in the Examples folder in the above link.

Details

report.rb

  • Class: Report()
  • Functions:
    • set_rdl_path(path_to_rdl_file)
    • export(export_type, save_path)
      • export_type: "pdf", "csv", "xslx", "xml", "rtf", "tif", "html"
        • If type does not match it will default to pdf
      • save_path: the directory path and file name that will be generated
    • export_to_memory(export_type)
      • export type: "pdf", "csv", "xslx", "xml", "rtf", "tif", "html"
      • If type does not match it will default to pdf

config.rb

Set the paths to mono, rdlcmd, and set if on windows or not.

Examples

Example of calling a basic report and generating the file hello2.pdf.

$LOAD_PATH << '../'
require 'report'

rpt = Report.new
rpt.set_rdl_path('C:/path/to/SimpleTest1.rdl')
rpt.export("pdf", "C:/path/to/hello2.pdf")

Example generating a report that has a parameter. Multiple parameters can be added using the set_parameter function. This example generates the file hello.pdf.

$LOAD_PATH << '../'
require 'report'

rpt = Report.new
rpt.set_rdl_path('C:/path/to/SimpleTestConnectionString.rdl')
rpt.set_parameter("ConnectionString", 'Data Source=C:/path/to/SqliteDatabaseFile.db;Version=3;Pooling=True;Max Pool Size=100;')
rpt.export("pdf", "C:/path/to/hello3.pdf")