def to(format, *args)
      options = extract_options!(args)
      datasource = args[0]
      file = Tempfile.new("to_#{format}")
      exporter = Beardley.with_warnings { Rjb.import(Beardley.exporters[format]) }.new
      _JRExporterParameter = Rjb.import('net.sf.jasperreports.engine.JRExporterParameter')
      exporter.setParameter(_JRExporterParameter.JASPER_PRINT, prepare(datasource))
      exporter.setParameter(_JRExporterParameter.OUTPUT_FILE_NAME, file.path.to_s)
      exporter.exportReport
      file.rewind
      report = file.read
      file.close(true)
      report
    end
def to(format, *args)
      options = extract_options!(args)
      datasource = args[0]
      file = Tempfile.new("to_#{format}")
      exporter = Beardley.with_warnings { Rjb.import(Beardley.exporters[format]) }.new
      _JRExporterParameter = Rjb.import('net.sf.jasperreports.engine.JRExporterParameter')
      exporter.setParameter(_JRExporterParameter.JASPER_PRINT, prepare(datasource))
      exporter.setParameter(_JRExporterParameter.OUTPUT_FILE_NAME, file.path.to_s)
      exporter.exportReport
      file.rewind
      report = file.read
      file.close(true)
      report
    end
Generic method to export to some format like ODT and DOCX