Pregunta

Crystal Reports vb.net crystalreportviewer export to text

I have a .net program that calls crystal reports. I was wondering if you can capture the values that are entered when you load a crystal report

enter image description here

I figured out I can view the parameters when i debug I am just not sure how to grab the values

I want the StartValue and EndValue in this picture http://i.stack.imgur.com/ThO6j.png

enter image description here

¿Fue útil?

Solución

What I ended up doing which worked was add a button to the crystal report viewer page.. after the crystal report toolbar

then on click I had this code

    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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top