JLReprot 报表工具说明

L

JLReport 介绍

简介

      JLReport 是一种用java开发的适合交叉表开发的软件包,主要是通过配置文件来描述报表的格式。可以直接输出表样,也可以去的数据开发人员根据自己的要求输出表样。

配置文件说明

<parameter>   变量说明

       <JrerpotQuery>     sql语句

       <lReaportTop>       表的顶端描述

       <JLReportMidist>  表的中间值的描述

       <JLReprotRow>    表的行描述

       <lEachcolumn>      取所有值

       <lColumn>            取指定值

       <lReportCount>     合计

       <JLReprotLine>     表的列说明

       <textout>                     每个域表现形式说明

      

举例说明

       <?xml version="1.0" encoding="GB2312"?>

<lTemplate>   

              <parameter name="ksrq" sclass="java.lang.String"/> /*参数起始日期*/

              <parameter name="zzrq" sclass="java.lang.String"/> /*参数终止日期*/

              <JRerpotQuery  name="query" value="select ffjdm,yjzl,jdjdm sl zl from qqdxxb a               where  gdrq&#x3E;= to_date('$[ksrq]','yyyymmdd') and gdrq&#x3C;to_date('$[zzrq]','yyyymmdd')  " />       /*sql语句*/

                           

              <lReaportTop name="JLReportTextTop" >

                     <textout type="JLReportTextTop" value="邮件封发统计表" />

              </lReaportTop>  /*表的顶端描述*/

              <JLReportMidist name="数量" func="sum" value="sl" >

                     <textout type="JLReportText" value="$[sl]" /> /*表现形式说明*/

              </JLReportMidist> /*表的中间值的描述 数量*/

              <JLReportMidist name="重量" func="sum" value="zl" >

                     <textout type="JLReportText" value="$[zl]" />

              </JLReportMidist>/*表的中间值的描述重量*/

             

              <JLReprotRow name="中心局"  value="ffjdm"> /*   表的行描述 取封发局*/          

                     <lEachcolumn value="ffjdm" > /*取每一行*/

                            <textout type="JLReportTextQuery" value="select jgjc from tjgdm where jgdm='$[ffjdm]'" />  /*表现形式说明 将机构代码翻译成机构简称*/

                     </lEachcolumn>

                     <lReportCount value="" >/*合计*/

                            <textout type="JLReportText" value="合计" />   

                     </lReportCount>                        

                     <JLReprotRow name="邮件种类" value="yjzl" >   /*       表的行描述 嵌套邮件种类*/

                            <lEachcolumn name="邮件种类" value="yjzl" >

                                   <textout type="JLReportText" value="select yjzljc from tyjzlb where yjzlbh='$[yjzl]'" />

                            </lEachcolumn>

                            <lReportCount name="合计"  value="合计" >

                                   <textout type="JLReportText" value="小计" />   

                            </lReportCount>   

                     </JLReprotRow>                                                          

              </JLReprotRow>         

              <JLReprotLine name=" 寄达局" value="jdjdm" > /*    表的列描述 取寄达局*/   

                     <lEachcolumn  value="yjzl" >

                            <textout type="JLReportTextQuery" value="select jgjc from tjgdm where jgdm='$[jdjdm]'" />

                     </lEachcolumn>

                     <lReportCount   value="合计" >

                            <textout type="JLReportText" value="合计" />   

                     </lReportCount>   

                      <JLReprotLine name="邮件种类" value="yjzl" >       /*    表的列描述套邮件种类*/

                            <lColumn  value="001" > /*取指定的为001的邮件种类*/

                                   <textout type="JLReportTextQuery" value="select yjzljc from tyjzlb where yjzlbh='$[yjzl]'" />

                               </lColumn>

                            <lColumn  value="025" >

                            <textout type="JLReportTextQuery" value="select yjzljc from    tyjzlb where yjzlbh='$[yjzl]'" />

                            </lColumn>

                             <lColumn  value="072" >

                                        <textout type="JLReportTextQuery" value="select yjzljc from      tyjzlb where yjzlbh='$[yjzl]'" />

                               </lColumn>

                     <lReportCount value="合计" >

                            <textout type="JLReportText" value="小计" />

                        </lReportCount>

                     </JLReprotLine>                 

       </JLReprotLine>

</lTemplate>

对应的报表演示

      

说明

       1     <lTemplate>  每个配置文件必须包括

 

       2     <parameter name="ksrq" sclass="java.lang.String"/> /*参数起始日期*/

              <parameter name="zzrq" sclass="java.lang.String"/> /*参数终止日期*/

              参数说明 可以没有

              配置文件其他地方可以通过$[]引用 例如$[ksrq] $[zzrq]

对于              <JLReportMidist>       <JLReprotRow>    <JLReprotLine> value 我们

也可以用$[]引用

      

3     <JRerpotQuery  name="query" value="select ffjdm,yjzl,jdjdm sl zl from qqdxxb a               where  gdrq&#x3E;= to_date('$[ksrq]','yyyymmdd') and gdrq&#x3C;to_date('$[zzrq]','yyyymmdd')  " />     /*sql语句*/

                    sql语句可以有,如果没有,在调用是必须传入sql语句 。由于xml 文件中属性说明中不能出现> ‘>.’ ‘<’ 等特殊字符 只能对应的 16为之代替前面加&#x  代替。 &#x3E; 表示>  &#x3C; 表示<

      

       4     <lReaportTop name="JLReportTextTop" >

                     <textout type="JLReportTextTop" value="邮件封发统计表" />

              </lReaportTop>  /*表的顶端描述*/

 

       5     <JLReprotRow name="中心局"  value="ffjdm"> /*   表的行描述 取封发局*/          

                     <lEachcolumn value="ffjdm" > /*取每一行*/

                            <textout type="JLReportTextQuery" value="select jgjc from tjgdm where jgdm='$[ffjdm]'" />  /*表现形式说明 将机构代码翻译成机构简称*/

                     </lEachcolumn>

                     <lReportCount value="" >/*合计*/

                            <textout type="JLReportText" value="合计" />  

                     </lReportCount>                      

                     <JLReprotRow name="邮件种类" value="yjzl" >   /*      表的行描述 嵌套邮件种类*/

                            <lEachcolumn name="邮件种类" value="yjzl" >

                                   <textout type="JLReportText" value="select yjzljc from tyjzlb where yjzlbh='$[yjzl]'" />

                            </lEachcolumn>

                            <lReportCount name="合计"  value="合计" >

                                   <textout type="JLReportText" value="小计" />  

                            </lReportCount> 

                     </JLReprotRow>                                                         

              </JLReprotRow>        

             

              <JLReprotRow> 表示

 

 

       5     <JLReportMidist name="数量" func="sum" value="sl" >

                     <textout type="JLReportText" value="$[sl]" /> /*表现形式说明*/

              </JLReportMidist> /*表的中间值的描述 数量*/

              <JLReportMidist name="重量" func="sum" value="zl" >

                     <textout type="JLReportText" value="$[zl]" />

     使用说明

public class test {

               public static void main(String[] args)

               {

              try {      

                     Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

                     Connection conn= DriverManager.getConnection(" jdbc:oracle:thin:@10.2.17.81:1521:yz","zxj","post");               

                     String qsrq="20001001"; /

                     String zzrq="20051201";

                     Map map=new HashMap();

                     map.put("ksrq",qsrq);  /*压入参数起始日期*/

                     map.put("zzrq",zzrq);     /*压入终止起始日期*/

                     JLReport lre1=new JLReport();

                     lre1.Parse("yjzl.xml");    /*分析配置文件*/

                     lre1.CreateData(map,"",conn);/*计算数据*/

                     lre1.OutToFile();    /*产生结果*/                             

              /*将结果返回*/

                    

                     conn.commit();

                     conn.close();

             

                    

              }

              catch (Exception sqle) {

                     sqle.printStackTrace();

                     throw new WebException(WebError.ADMIN_DB_GET_RESOURCE , "取出数据失败" , sqle);

              }

              finally

              {

                     try{

                            if (conn!=null )

                            {

                                   if(conn.isClosed()!=true)

                                   {

                                          conn.rollback();

                                          conn.close();

                                   }

                            }

                     }

                     catch (SQLException sqlex2)

                     {

                            System.out.print(this.getClass().getName() + ".mymethod - 不能关闭数据库连接: " + sqlex2.toString());

                            throw new WebException(WebError.ADMIN_DB_GET_RESOURCE , "关闭数据库连接失败" , sqlex2);

                     }

 

              }

 

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页