2013-04-18 71 views
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; 
    } 

在上面的代碼我設置了一個條件,如果我需要像表格一樣的確切邊界,我如何實現它

回答

0

它的衝突使用Dyanamicjasper3.0.6,因爲它沒有正確包含邊界類,當你使用Dynamicjasper 4.0.3和3.0。 6相同項目,所以它只考慮3.0.6而不是4.0.3。所以刪除3.0.6並使用4.0.3它肯定工作。

+0

這對我有用。 – sath