0

Crystal Reports vb.net crystalreportviewer 导出为文本

我有一个调用水晶报告的.net 程序。我想知道您是否可以捕获加载水晶报告时输入的值

在此处输入图像描述

我发现调试时可以查看参数我只是不确定如何获取值

我想要这张图片中的 StartValue 和 EndValue http://i.stack.imgur.com/ThO6j.png

在此处输入图像描述

4

1 回答 1

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
于 2013-09-18T15:44:27.633 回答