简体   繁体   English

Jasper是否支持xml文件作为数据源?

[英]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确实支持基于XML的数据源,您可以按照使用任何其他数据源创建报表的方式创建报表。 Jasper has an abstraction from datasources which you provide to ensure it behaves the same (or atleast similarly) with different datasources. Jasper从数据源中抽象出来,以确保它与不同数据源的行为相同(或至少类似)。

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: 以下是我为xml文件测试的代码示例,作为数据源,输出为PDF报告:

    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>");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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