以XML文件作为数据源的话,在数据源的脚本中可写:
importPackage(Packages.java.lang);
importPackage(Packages.java.util);
importPackage(Packages.java.io);
importPackage(Packages.java.net);
var appath = reportContext.getHttpServletRequest().getRequestURL();
System.out.println("路径为:"+appath.substring(0,appath.indexOf("frameset")));
//动态取得XML文件数据源
this.setExtensionProperty("FILELIST",appath.substring(0,appath.indexOf("frameset"))+"printXMLFile/second_file.xml")
以SQL为数据源的话,在数据集的脚本中可以为:
importPackage(Packages.java.lang);
importPackage(Packages.java.util);
importPackage(Packages.java.io);
importPackage(Packages.java.net);
var session =reportContext.getHttpServletRequest().getSession();
var user = session.getAttribute("CUserBean");
var type = user.getType()+"";
var start = params["start"]+"";
var end = params["end"]+"";
var deptid = user.getDeptId()+"";
var userid = user.getId()+"";
var par_deptid = params["deptid"]+"";
this.queryText="";
var sql=" select t.aaa,t.bbb from t_test_table";
if(start!="null" && start.length()>0){
sql+=" and to_char(t.CREATETIME,'yyyy-MM-dd' ) >= '"+start+"'";
}
if(end!="null" && end.length()>0){
sql+=" and to_char(t.CREATETIME,'yyyy-MM-dd' ) <= '"+end+"'";
}
if(type=='1'){
if(par_deptid!="null"&& par_deptid.length()>0){
sql+=" and u.deptid='"+par_deptid+"'";
}
}else if(type=='2'){
if(deptid!=null&&deptid!=""){
sql+=" and u.deptid='"+deptid+"'";
}
}else{
if(deptid!=null&&deptid!=""){
sql+=" and u.deptid='"+deptid+"'"+ " and u.id='"+userid+"'";
}
}
sql+=" order by d.shortname asc";
this.queryText=sql;
//System.out.println(this.queryText);
阅读(1479) | 评论(0) | 转发(0) |