用友UAP报表高级开发之输出事件.docx
- 文档编号:4316021
- 上传时间:2022-11-29
- 格式:DOCX
- 页数:11
- 大小:275.77KB
用友UAP报表高级开发之输出事件.docx
《用友UAP报表高级开发之输出事件.docx》由会员分享,可在线阅读,更多相关《用友UAP报表高级开发之输出事件.docx(11页珍藏版)》请在冰豆网上搜索。
用友UAP报表高级开发之输出事件
报表输出事件
1.原理
运用.net动态编译原理,所以语法上完全遵守c#语法规则,写的代码要在运行时期取编译运行的
2.执行时间
加载完数据和个时候,要呈现前把该脚本功能应用上
3.报表元数据组成:
C#标准语法和报表中已经存在的变量组成
4.脚本对象:
4.1.filter
【功能介绍】
过滤条件对象,获取过滤条件中的值
【对象函数】
返回过滤条件区间初始值(编码):
stringGetValue1(stringkey);
返回过滤条件区间结束值(编码):
stringGetValue2(stringkey);
返回过滤条件区间初始值(名称):
stringGetName1(stringkey);
返回过滤条件区间结束值(名称):
stringGetName2(stringkey);
【用例】
filter.GetValue1("订单号")
4.2.global
【功能介绍】
全局对象,定义全局变量
【对象函数】
执行SQL语句:
objectExecuteScalar(stringsql)
执行SQL语句并返回结果:
DataSetExecute(stringsql)
报表中的全局变量:
.varent----定义的全局变量
【用例】
global.ExecuteScalar("selecttop1ccodefromSA_Sale");
global.A A为报表中定义的全局变量
4.3.current
【功能介绍】
获取当前行
【对象函数】
获取当前行的某列(只有get):
objectcurrent[columnname]
获取当前行的某列:
.columnname -----列值
【用例】
current.订单号
current["订单号"]
定义
sb.Append("publicclassCurrent\r\n");
sb.Append("{\r\n");
sb.Append("privateRowData_rowdata;\r\n");
sb.Append("publicCurrent(RowDatarowdata)\r\n");
sb.Append("{\r\n");
sb.Append("_rowdata=rowdata;\r\n");
sb.Append("}\r\n");
sb.Append("publicobjectthis[stringname]\r\n");
sb.Append("{\r\n");
sb.Append("get\r\n");
sb.Append("{\r\n");
sb.Append("return_rowdata[name];\r\n");
sb.Append("}\r\n");
sb.Append("set\r\n");
sb.Append("{\r\n");
sb.Append("_rowdata[name]=value;\r\n");
sb.Append("}\r\n");
sb.Append("}\r\n");
4.4.privious
【功能介绍】
获取前一行
【对象函数】
获取前一行的某列:
objectprevious[columnname]
获取前一行的某列:
.columnname -----列值
【用例】
previous.订单号
previous["订单号"]
【功能介绍】
获取系统参数
【对象函数】
执行SQL语句:
voidExecuteNonQuery(stringsql)
执行SQL语句,返回结果:
objectExecuteScalar(stringsql)
执行SQL语句,返回结果:
DataSetExec(stringsql)
在Meta库中执行SQL语句,返回结果:
DataSetExecFromMeta(stringsql)
用户名:
stringUserName
当前日期:
stringDate
当前时间:
stringTime
当前年:
intYear
当前月:
intMonth
当前日:
intDay
帐套年:
intAccountYear
帐套月:
intAccountMonth
用户自定义参数:
stringCusDefineInfo(stringkey)
公司信息:
stringCompanyInfo(stringkey)
【用例】
datahelper.CusDefineInfo("@存货.自定义项1")
4.5.args
【功能介绍】
传递参数
【对象函数】
取参数对象:
objectthis[stringkey]
取参数对象:
objectGetValue(stringkey);
【用例】
args["filterflag"]
4.6.indexs
【功能介绍】
分组索引
【对象函数】
startindex ---每一分组的开始序号
endindex ---每一分组的结束序号
currentindex ---当前序号
4.7.groups
【功能介绍】
分组函数,获取报表的分组情况及指定分组
【对象函数】
取指定分组:
Groupthis[intindex]
取分组级次:
intLevels{get;}
取此组的分组数:
intCount{get;}
4.8.currenggoup
【功能介绍】
分组函数,获取当前组信息
【对象函数】
获取分组:
stringthis[stringname]
获取下级分组:
GroupsChildGroups
获取上级分组:
GroupParent
分组的可见性:
boolVisible
分组的级次:
intLevel
4.9.Cells
【功能介绍】
字段组函数,获取指定字段
【对象函数】
获取指定列:
Cellthis[stringname]
cell.Caption=cells["cInvCode"].ToString();
4.10.Report
【功能介绍】
报表对象,获取报表信息
【对象函数】
获取报表的分组级次:
intGroupLevels
获取二次过滤条件:
string RowFilter.FilterString
string GroupFilter
reportsummaryData
【功能介绍】
报表汇总对象,获取报表的汇总信息
【对象函数】
获取指定字段的汇总数:
Doublethis[stringmapname]
【用例】
this["存货数量"]
5.例子
5.1.根据已有内容,动态显示另外一个值比“数据权限查询”报表中的有权
if(cell.Value.ToString().Trim()=="1")
cell.Caption="√";
else
cell.Caption="";
5.2.获取当前登陆语言,并且动态显示列名称
if(cell.Value.ToString().Trim()=="")
{
if(datahelper.Login.LocaleID.ToLower()=="zh-cn")
cell.Caption="来源自身";
if(datahelper.Login.LocaleID.ToLower()=="zh-tw")
cell.Caption="來源自身";
if(datahelper.Login.LocaleID.ToLower()=="en-us")
cell.Caption="InheritFromSelf";}
5.3.根据不同值,显示不同的背景色,起醒目提示作用
if(Convert.ToDouble(cell.Value)>100000)
cell.ForeColor=Color.Red;
效果】
∙"销售额"字段按上述条件变化背景色;"提成额"按上述条件设置为红色。
5.4.计算逻辑
复杂计算列,需要根据上一行内容来动态计算,完全是靠代码写出来的
如应付总账表中的余额本币列
if(currentindex==0)
{
//current.ye=current.ye+current.jf-current.df-current.jf2+current.df2;
}
else
{
current.ye=previous.ye+current.jf-current.df-current.jf2+current.df2;
}
returncurrent.ye;
6.附录(编译后的具体代码)
publicclassCellcWhName:
ICellEvent
{
publicvoidPrepaint(Reportreport,RowDatadata,Cellinnercell,FilterSrvfilter,AgileArgsargs,DataHelperdatahelper,ReportSummaryDatareportsummary,RowBalancerowbalance,AccumulateDataaccumulate,BalanceDatabalance,object[]others)
{
Currentcurrent=null;
intgrouplevels=report.GroupLevels;
intcurrentindex=-1;
intstartindex=-1;
Groupsgroups=null;
Groupcurrentgroup=null;
RowDatacolumntodata=null;
Currentprevious=newCurrent(rowbalance);
if(rowbalance!
=null)
{
currentindex=rowbalance.CurrentIndex;
startindex=rowbalance.StartIndex;
}
SemiRowcells=(data!
=null?
data.SemiRow:
null);
SemiRowrow=cells;
IKeyToObjectnametodata=cellsasIKeyToObject;
StimulateCellcell=newStimulateCell(innercell);
if(dataisGroup)
{
cell.bInGroup=true;
currentgroup=dataasGroup;
columntodata=currentgroup;
}
elseif(!
(dataisReportSummaryData))
{
current=newCurrent(data);
columntodata=data;
}
else
{
cell.bInReportSummary=true;
columntodata=data;
}
if(nametodata==null)
{
nametodata=columntodataasIKeyToObject;
}
Globalglobal;
if(datahelper.Global==null)
{
global=newGlobal();
global.DataHelper=datahelper;
datahelper.Global=global;
}
else
{
global=datahelper.GlobalasGlobal;
}
//cell.Caption=current.Function0;
//(cells["cWhName"]asCell).Caption=current.Function0;
cell.Caption=cells["cInvCode"].ToString();
cell.Caption=report.GroupLevels;
}
}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 用友 UAP 报表 高级 开发 输出 事件