发布时间 : 2015-12-10 09:34:30.000|阅读 2250 次
概述:本片文章主要介绍Stimulsoft Reports.Net开发者在处理变量时遇到的常见问题及解决方案。
相关链接:
< Stimulsoft Reports.Net v2015.3最新版本下载>
可以使用以下代码来实现给报表添加变量。
添加int型的MyVariable变量代码示例:
C#
report.Dictionary.Variables.Add(new StiVariable("Category", "MyVariable", typeof(int), "1", false));
VB
Report.Dictionary.Variables.Add(New StiVariable("Category", "MyVariable", CType(GetType(int), Type),
"1", False))
添加string型的MyVariable变量代码示例:
C#
report.Dictionary.Variables.Add(new StiVariable("Category", "MyVariable", typeof(string), "1", false));
VB
Report.Dictionary.Variables.Add(New StiVariable("Category", "MyVariable", CType(GetType(String),
Type), """1""", False))
要访问变量的值,你可以使用以下代码:
C#
StiReport report = new StiReport();
report.Load("Variables.mrt");
report.Compile();
//设置变量
report["VariableName"] = "Value";
//获取变量
object value = report["VariableName"];
VB
Dim Report As StiReport = New StiReport()
Report.Load("Variables.mrt")
Report.Compile()
'设置变量
Report.Item("VariableName") = " Value "
'获取变量
Dim Value As Object = Report.Item("VariableName")
使用以下代码:
text1.Text = "{PageNofM}";
购买最新正版授权!"咨询在线客服"
慧都年终盛典火爆开启,一年仅一次的最强促销,破冰钜惠不容错过!!优惠详情点击查看>>
渝ICP备12000582号-15/渝公网安备 50010702501010号