Sunday, September 14, 2008

Using Generic lists with crystal reports in .net

Public Sub ReportDocumentListDetails(ByVal rptPath As String, ByVal reportname As String, ByVal rptdoc As CrystalDecisions.CrystalReports.Engine.ReportDocument, _

ByVal arListName As System.Collections.ArrayList, ByVal arListValue As System.Collections.ArrayList)

Dim rptViewer As New CrystalDecisions.Windows.Forms.CrystalReportViewer()

Dim ds As DatasetReport = New DatasetReport

If (arListName.Count = arListValue.Count) Then

For i As Integer = 0 To arListName.Count - 1

rptdoc.SetParameterValue(arListName(i).ToString, arListValue(i))

Next

End If

Dim objExOpt As CrystalDecisions.Shared.ExportOptions

Dim objDiskOpt As New CrystalDecisions.Shared.DiskFileDestinationOptions

objDiskOpt.DiskFileName = "F:\nath\" & reportname & ".pdf"

objExOpt = rptdoc.ExportOptions

objExOpt.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile

objExOpt.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat

objExOpt.DestinationOptions = objDiskOpt

rptdoc.Export(objExOpt)

rptdoc.Close()

End Sub

No comments: