JRDataset属性CSV文件 [英] JRDataset property CSV file

查看:100
本文介绍了JRDataset属性CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用.CSV输入文件作为DataAdapter的报告。之后,我需要一个表将一些数据放入其中以及一个链接的数据集。问题是:如果我在Dataset1中的默认数据适配器部分保留空白,将不会显示任何数据。实际上,要修复此报告,我必须将DataAdapter导出为myDataAdapter.xml,然后将此文件放在我的 Dataset1 默认数据适配器部分中(如下所示)在附图中)。

I have a build up a report with a .CSV input file as DataAdapter. After that I needeed a table to put some data into a it and a linked dataset. The problem is: if I leave blank the section "Default Data Adapter" in my Dataset1, no data will be displayed. In fact, to fix this report I had to export my DataAdapter as myDataAdapter.xml and then put this file in the section "Default Data Adapter" of my Dataset1 (as shown in the attached picture).

使用数据库我从未设置过此属性。

Working with database I have never set up this property.

有没有办法将此属性作为Param传递? (我有一个Java代码,我在其中调用jasperReport,并希望通过动力学方式传递该对象。)

Is there a way to pass this property as Param? (I have a java code in which I call jasperReport and I want to pass this object dinamically).

或者在不设置此属性的情况下报表是否可以工作?

Or is there a way the report works without setting this property?

在表>数据集部分中,我遇到这种情况:

In the section Table>Dataset I have this situation:

在这里设置JRDatasource表达式,但是它不起作用...

where I set up JRDatasource expression, but it is not working...

我有一个更多问题。我可以在DataAdapter.xml中动态设置.csv的位置吗?

I have one more problem. Can I set dinamically the location of my .csv inside the DataAdapter.xml?

是否可以通过Java代码实现 myDataAdapter.xml并将其传递给报告?

Is it possible to implement "myDataAdapter.xml" from java code and pass it to the report??

请先谢谢您!

推荐答案

在Java代码中,您可以在 net.sf.jasperreports.engine.JasperReport 实例此处,来自官方存储库。相关代码如下:

In Java code you can set properties on the net.sf.jasperreports.engine.JasperReport instance like in this sample here, from the official repository. The relevant code looks like this:

...
JasperReport jasperReport = ...
...
jasperReport = (JasperReport)JRLoader.loadObjectFromFile("build/reports/ExcelXlsxQeDataAdapterReport.jasper");
jasperReport.setProperty(DataAdapterParameterContributorFactory.PROPERTY_DATA_ADAPTER_LOCATION, "data/XlsxQeDataAdapter.xml");
...

感兴趣的财产是 net.sf .jasperreports.data.adapter 并存储在 DataAdapterParameterContributorFactory.PROPERTY_DATA_ADAPTER_LOCATION

The property of interest is net.sf.jasperreports.data.adapter and is stored in DataAdapterParameterContributorFactory.PROPERTY_DATA_ADAPTER_LOCATION

数据中适配器文件是一种方便的方法,可以传递一系列参数,从这些参数中构建 net.sf.jasperreports.engine.data.JRCsvDataSource 。如果要跳过传递此属性,则必须手动提供 net.sf.jasperreports.engine.query.JRCsvQueryExecuterFactory.CSV_BUILTIN_PARAMETERS

The data adapter file is a convenience method to pass a series of parameters from which a net.sf.jasperreports.engine.data.JRCsvDataSource is built. If you want to skip passing this property, you would have to manually provide the built-in parameters listed in the net.sf.jasperreports.engine.query.JRCsvQueryExecuterFactory.CSV_BUILTIN_PARAMETERS.

这篇关于JRDataset属性CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆