如何通过编码动态设置水晶报表的标题 [英] How to set title of crystal report dynamically with coding

查看:70
本文介绍了如何通过编码动态设置水晶报表的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在使用Crystal Report.我想使用vb.net中非静态的编码来动态生成水晶报表的标题.报告标题应该是动态的,这意味着如果我已经从组合中选择了并且我想在报告标题中显示所选的项目,那么它应该显示在水晶报告标题中.

帮帮我..


[edit]已删除呼喊声-OriginalGriff [/edit]

Hello, i am working with crystal report. I want to do the crystal report''s title dynamically with the usage of coding not static in the vb.net. the report title should be dynamic means if I have selected from combo and I want to show that selected item in the report title , it should be display in the crystal report title.

Help me..


[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

Dim RPTTITLE As String
 
Try
Dim tmp As String
 
If ddlactive.SelectedItem.Text = "Yes" Then
tmp = "Y"

ds1 = con.FetchData("select * from computer_mast where type='" & ddlOpt.SelectedItem.Text & "' and active='" & tmp & "' order by deptname,ip ")
RPTTITLE = "Active " & ddlOpt.SelectedItem.Text & " Users"
ElseIf ddlactive.SelectedItem.Text = "No" Then
tmp = "N"
ds1 = con.FetchData("select * from computer_mast where type='" & ddlOpt.SelectedItem.Text & "' and active='" & tmp & "' order by deptname,ip ")
RPTTITLE = "Not Active " & ddlOpt.SelectedItem.Text & " Users"
End If
 
If ds1.Tables(0).Rows.Count > 0 Then
lblErr.Visible = False
rptname = "~/Reports/Report3.rpt"
con.con.Open()
rpt.Load(Server.MapPath(rptname))
rpt.SetDatabaseLogon("wml", "win")
rpt.SetDataSource(ds1.Tables(0))
rpt.SummaryInfo.ReportTitle = RPTTITLE
 
CrystalReportViewer1.ReportSource = rpt
 
rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "ExportedReport")
 
Else
lblErr.Visible = True
End If
con.dttemp = ds1.Tables(0)
Catch ex As Exception
MsgBox(ex.Message)
End Try


好吧,添加一个新的公式字段并将值从vb.net传递到该公式字段.

就这样.

希望这能解决您的问题.
Well, you can just add a new Formula Field and pass value to that formula field from your vb.net.

That''s it.

Hope this will solve your problem.


嗨Dipak.
您可以在Crystal Report Designer的特殊字段"部分中使用报告标题"或报告注释"或文件作者"字段,并将它们放置在Crystal报表的标题部分,并在编码中设置这些字段的值,如示例所示
hi Dipak.
u can use "Report Title" or "Report Comments" Or "File Author" Field in Special Fields Section of Crystal Report Designer and place them title section of your crystal report and set values of these fields in coding as shown example
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
      Me.ViewReceiptTableAdapter.Connection = Connection
      Me.ViewReceiptTableAdapter.FillByDate(Me.DSetFeeReports.ViewReceipt, Me.DtDate.Value)
      CryDailyCollection1.SummaryInfo.ReportTitle = " Report Of " & ComboCity.text & "City"
      CryDailyCollection1.SetDataSource(Me.DSetFeeReports)

      Me.CrystalReportViewer1.ReportSource = CryDailyCollection1

  End Sub



这是设置任何Crystal报表的动态标题的最简单方法.
我希望这能解决您的问题



This is easiest way to set dynamic Title of any crystal report.
i hope this solve your problem


这篇关于如何通过编码动态设置水晶报表的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆