【发布时间】:2014-06-24 10:56:05
【问题描述】:
我正在尝试使用 java 代码从 jrxml 文件制作 pdf,但它给了我以下错误:
SEVERE: Parse Error at line 2 column 487: Document root element "jasperReport", must match DOCTYPE root "null".
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 487; Document root element "jasperReport", must match DOCTYPE root "null".
......
我的代码:主类:
public class MainClass_Dummy {
public static JasperDesign jasperDesign;
public static JasperPrint jasperPrint;
public static JasperReport jasperReport;
public static String filename = "D://ReceiptReport.jrxml";
public static String outputreport = "D://test_jasper.pdf";
static JRBeanCollectionDataSource jrBeanCollectionDataSource;
public MainClass_Dummy(){
try{
System.out.println("Loading a jrxml file..");
FileInputStream input = new FileInputStream(new File(filename));
jasperDesign = JRXmlLoader.load(input);
jasperReport = JasperCompileManager.compileReport(jasperDesign);
jasperPrint = JasperFillManager.fillReport(jasperReport, null, jrBeanCollectionDataSource);
Desktop.getDesktop().open(new File("D:/ReceiptReport.pdf"));
}catch(Exception e){e.printStackTrace();}
}
public static void main(String[] args) {
Dummy_MainClass dm = new Dummy_MainClass();
new MainClass_Dummy(); }
}
它成功创建了jrxml,并且在ireport 5.5.0中运行良好,但是当我在eclipse中运行它时出现错误,请任何人有解决方案然后告诉我。
问候。
【问题讨论】:
-
您需要检查您的 jasper 报告的版本。 jasper 报告和 ireport 的版本应该相同。
标签: java jasper-reports