tuansandman Posted June 5, 2008 Share Posted June 5, 2008 Hi thereI've just create a very simple report (by iReport) with only one static text. When I export to RTF file, the only thing I receive is just a blank file. Does anyone know why. Please help me, it's very urgentThank you :) here is my ReportUtils.java ----------------------------------package com.miis.iol.util;import java.util.HashMap;import java.util.Map;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRExporterParameter;import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.JasperReport;import net.sf.jasperreports.engine.design.JasperDesign;import net.sf.jasperreports.engine.export.JRRtfExporter;import net.sf.jasperreports.engine.xml.JRXmlLoader;public class ReportUtils { /** * Generate Rich Text Format file from pre-design template * * @param designFile path of design template * @param outputFile output file * @param parameters parameters for this template */ public static void generateRTF( String designFile, String outputFile, Map parameters ) throws JRException { JasperDesign jasperDesign = JRXmlLoader.load( designFile ); JasperReport jasperReport = JasperCompileManager.compileReport( jasperDesign ); JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, new HashMap() ); JRRtfExporter rtfExporter = new JRRtfExporter(); rtfExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint ); rtfExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outputFile ); rtfExporter.exportReport(); } // end of generateRTF public static void main( String[] args ) { try { String inputFile = "c:\temp\staticJasper.jrxml"; String outputFile = "C:/temp/StaticReport.rtf"; ReportUtils.generateRTF(inputFile, outputFile, new HashMap() ); } catch ( Exception e ) { e.printStackTrace(); } }}---------------------------------------here is my design file (create by iReport) - http://www.box.net/shared/7r87dkbccg [/code] [file name=StaticJasper.jrxml size=1971] Link to comment Share on other sites More sharing options...
lucianc Posted June 5, 2008 Share Posted June 5, 2008 See this FAQ. Regards,Lucian Link to comment Share on other sites More sharing options...
tuansandman Posted June 6, 2008 Author Share Posted June 6, 2008 I have tried both I still received empty report. Do you know another solution thanksTuanNA Link to comment Share on other sites More sharing options...
lucianc Posted June 6, 2008 Share Posted June 6, 2008 Since the text you want to see is placed on the detail band, you'll need to pass some data when filling the report. Try something like Code: Regards, Lucian Link to comment Share on other sites More sharing options...
tuansandman Posted June 17, 2008 Author Share Posted June 17, 2008 yeah, thank you very much TuanNA Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now