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

问题描述

您好,我正在使用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



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


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

10-29 18:19