0

嗨,我是 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;
   }

在上面的代码中,我设置了一个条件,如果表格我需要像表格一样的精确边框,我该如何实现它

4

1 回答 1

0

它使用Dynamicjasper3.0.6的冲突是因为它没有正确包含边框类,当你在同一个项目中使用Dynamicjasper 4.0.3和3.0.6时,它只考虑3.0.6而不是4.0.3。所以删除 3.0.6 并使用 4.0.3 它肯定可以工作。

于 2013-04-23T13:57:59.513 回答