NET的水晶报表 [英] Crystal report with .Net
本文介绍了NET的水晶报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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 and some text also , it should be display in the crystal report title. i had selected item from combo is "AHMEDABAD".
i want to display Report Title as below.
Report Of Ahmedabad City
推荐答案
嗨迪帕克.
您可以在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 SubEnd SubEnd Subtion1
End Sub
我希望这能解决您的问题
i hope this solve your problem
将RPTTITLE设置为字符串
试试
昏暗的tmp作为字符串
如果ddlactive.SelectedItem.Text =是",则
tmp ="Y"
ds1 = con.FetchData("select * from computer_mast,其中type =''"&ddlOpt.SelectedItem.Text&''和active ="''&tmp&''按deptname,ip")排序)
RPTTITLE =活动"&ddlOpt.SelectedItem.Text&用户"
ElseIf ddlactive.SelectedItem.Text =否"然后
tmp ="N"
ds1 = con.FetchData("select * from computer_mast,其中type =''"&ddlOpt.SelectedItem.Text&''和active ="''&tmp&''按deptname,ip")排序)
RPTTITLE =未激活"&ddlOpt.SelectedItem.Text&用户"
如果结束
如果ds1.Tables(0).Rows.Count> 0然后
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")
其他
lblErr.Visible = True
如果结束
con.dttemp = ds1.Tables(0)
异常捕获
MsgBox(ex.Message)
结束尝试
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
这篇关于NET的水晶报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文