How to use JasperDesignViewer to preview a JasperReport?
Posted
by Jonas
on Stack Overflow
See other posts from Stack Overflow
or by Jonas
Published on 2010-04-27T17:51:43Z
Indexed on
2010/04/27
17:53 UTC
Read the original article
Hit count: 857
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>
© Stack Overflow or respective owner