我已经从marketPlace安装了Jaspersoft Studio插件。我创建了一个java项目并将其转换为Maven以导入Jasper报告jar。之后我创建了一个Blank_A4.jrxml
文件。因此,我在本教程中添加了一些java类
https://www.tutorialspoint.com/jasper_reports/jasper_filling_reports.htm
如下面的屏幕截图所示。
问题是当运行.jrxml文件时,还没有.jasper文件正在生成。有谁知道问题是什么?
我已更改此课程中sourceFileName
的路径:
package com.tutorialspoint;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
public class JasperReportFill {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
String sourceFileName =
"C://Users/alex.tree/Documents/iReport Designer workspace/Blank_A4.jasper";
DataBeanList DataBeanList = new DataBeanList();
ArrayList<DataBean> dataList = DataBeanList.getDataBeanList();
JRBeanCollectionDataSource beanColDataSource =
new JRBeanCollectionDataSource(dataList);
Map parameters = new HashMap();
/**
* Passing ReportTitle and Author as parameters
*/
parameters.put("ReportTitle", "List of Contacts");
parameters.put("Author", "Prepared By Manisha");
try {
JasperFillManager.fillReportToFile(
sourceFileName, parameters, beanColDataSource);
} catch (JRException e) {
e.printStackTrace();
}
}
}