How to use JasperDesignViewer to preview a JasperReport?
- by Jonas
I'm trying to use JasperReports for the first time, and have written a "Hello World"-document. But I don't know how I can preview my document with JasperDesignViewer. My .jrxml-file compiles fine to a .jasper-file. How do I call JasperDesignViewer? I'm not using Ant.
My Java code:
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.view.JasperDesignViewer;
public class ReportTest {
public static void main(String[] args) {
try {
JasperCompileManager.compileReportToFile("reports/ReportFile.jrxml");
//new JasperDesignViewer();
} catch (JRException e) {
e.printStackTrace();
}
}
}
My JRXML-file:
<?xml version="1.0"?>
<!DOCTYPE jasperReport
PUBLIC "-//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="FirstReport">
<detail>
<band height="20">
<staticText>
<reportElement x="180" y="0" width="200" height="20"/>
<text><![CDATA[Hello World!]]></text>
</staticText>
</band>
</detail>
</jasperReport>