您好我是dynamicjasper的新手,我创建了子报告,但是当我使用setBorder属性将边框设置为我的子报告时,它会引发异常java.lang.reflect.InvocationTargetException
这是子报告代码
public DynamicReport buildReport() throws Exception {
FastReportBuilder frb = new FastReportBuilder();
frb.setTitle("PROJECT DOCUMENTATION")
.setMargins(5, 5, 20, 20);
frb.addColumn("","project_id", String.class.getName(), 30)
.addColumn("","product_name",String.class.getName(),30)
.setQuery("select * from project_master where project_id=$P{project_id}", DJConstants.QUERY_LANGUAGE_SQL);
SIZE = table_name.size();
delete_table = table_name;
System.out.println("SIZE = = = "+SIZE);
frb.addGroups(2);
for(int s=0;s<table_name.size();s++){
System.out.println(" s "+s+" = "+table_name.get(s).toString()+" s_n "+seciton_name.get(s).toString()+" tab_type "+table_type.get(s).toString());
frb.addSubreportInGroupHeader(2, subreport(table_name.get(s).toString(),seciton_name.get(s).toString(),table_type.get(s).toString()),getLayoutManager
(),"getDataSourceSubreport"+s,DJConstants.SUBREPORT_PARAMETER_MAP_ORIGIN_PARAMETER,DJConstants.DATA_SOURCE_TYPE_JRDATASOURCE);
params.put("getDataSourceSubreport"+s, getDataSourceSubreport(table_name.get(s).toString()));
}
frb.setPrintBackgroundOnOddRows(true);
frb.setUseFullPageWidth(true);
params.put("project_id","PJT/0001");
return dr;
}
public DynamicReport subreport(String tab_name,String tit_name,String tab_type)throws Exception{
**Style tbl_border = new Stryle();
tbl_border.setBorder(Border.THIN());** //***Error occured in the line***
FastReportBuilder drb1 = new FastReportBuilder();
if(tab_type.equals("textarea")){
int max_width = 0;
Statement st5 = connection.createStatement();
ResultSet rs5 = st5.executeQuery("select column_name from information_schema.columns where table_name='"+tab_name+"'");
while(rs5.next()){
System.out.println("inside while textarea");
if(max_width>=1){
drb1.addColumn("",rs5.getString(1).toString(),String.class.getName(),25);
}
max_width++;
}
drb1.setUseFullPageWidth(true);
}
if(tab_type.equals("table")){
int max_width =0;
Statement st5 = connection.createStatement();
ResultSet rs5 = st5.executeQuery("select column_name from information_schema.columns where table_name='"+tab_name+"'");
while(rs5.next()){
System.out.println("inside while");
**drb1.addColumn(rs5.getString(1).toString(),rs5.getString(1).toString(),String.class.getName(),25)addStyle(tbl_border);**
max_width++;
}
if(max_width>2){
drb1.setUseFullPageWidth(true);
}
}
// for(int sg=0;sg<header.size();sg++){
// drb1.addColumn(header.get(sg).toString(),header.get(sg).toString(),String.class.getName(),25);
// }
drb1.setSubtitle(tit_name);
drb1.setTitle("");
DynamicReport dr1 = drb1.build();
return dr1;
}
在上面的代码中我设置了一个条件,如果表格我需要像表一样的精确边框,我该怎样才能实现它
答案 0 :(得分:0)
使用Dyanamicjasper3.0.6进行冲突,因为它不正确地包含border类,当你在同一个项目中使用Dynamicjasper 4.0.3和3.0.6时它只考虑3.0.6而不是4.0.3。所以删除3.0.6并使用4.0.3肯定有效。