简体   繁体   中英

Do Jasper support xml file as the datasource?

我想知道JasperServer是否接受xml文件作为报告数据源,以及我们是否可以在我们对adhoc报告创建者中的各种数据源执行的xml节点上执行相同的操作,如拖放等等?

yes, jasper does support XML based datasources, you can create your report just the way you would create it using any other datasource. Jasper has an abstraction from datasources which you provide to ensure it behaves the same (or atleast similarly) with different datasources.

look here and here for some additional info

Here is the sample Code I tested for xml file as data source and out is PDF report:

    JasperReport jasperReport = JasperCompileManager.compileReport("<Path of jrxml file>");
    JRXmlDataSource xmlDataSource = new JRXmlDataSource("<Path of xml file>", "XPath Query");
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), xmlDataSource);
    JasperExportManager.exportReportToPdfFile(jasperPrint, "<Path of file PDF output file>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM