Crystal Reports vb.net crystalreportviewer导出到文本
我有一个调用水晶报告的.net程序。我想知道你是否可以捕获加载水晶报告时输入的值
我发现我可以在调试时查看参数我只是不确定如何获取值
我希望此图片中的StartValue和EndValue http://i.stack.imgur.com/ThO6j.png
答案 0 :(得分:0)
我最终做了哪些工作是在水晶报表查看器页面上添加一个按钮..在水晶报表工具栏之后
然后点击我有这个代码
Private Sub btnExport_Click(sender As System.Object, e As System.EventArgs) Handles btnExport.Click
Dim rangeval As New ParameterRangeValue
Dim discrete As New ParameterDiscreteValue
Dim name As String
Dim myReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim savefile As New SaveFileDialog
myReportDocument.Load(Me.CrystalReportViewer1.ReportSource)
For i = 0 To Me.CrystalReportViewer1.ParameterFieldInfo.Count - 1
If Me.CrystalReportViewer1.ParameterFieldInfo(i).CurrentValues(0).IsRange = True Then
name = (CrystalReportViewer1.ParameterFieldInfo(i).Name)
rangeval = CrystalReportViewer1.ParameterFieldInfo(i).CurrentValues.Item(0)
'MsgBox(rangeval.StartValue)
'MsgBox(rangeval.EndValue)
myReportDocument.SetParameterValue(name, rangeval)
ElseIf Me.CrystalReportViewer1.ParameterFieldInfo(i).CurrentValues(0).IsRange = False Then
name = (CrystalReportViewer1.ParameterFieldInfo(i).Name)
discrete = CrystalReportViewer1.ParameterFieldInfo(i).CurrentValues.Item(0)
'MsgBox(discrete.Value)
myReportDocument.SetParameterValue(name, discrete.Value)
End If
Next
savefile.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
savefile.Title = ("Save the text file")
If savefile.ShowDialog = Windows.Forms.DialogResult.OK Then
myReportDocument.ExportToDisk(ExportFormatType.Text, savefile.FileName)
End If
End Sub