joeyton
asked on
C# Crystal Reports
hi,
can anyone please help me, i am trying to populate a crystal report with the result of a stored procedure. when i have tried applying the dataset to the report i am returned with a blank report, i am lost on how to do this and would be very grateful for any solutions, thanks
can anyone please help me, i am trying to populate a crystal report with the result of a stored procedure. when i have tried applying the dataset to the report i am returned with a blank report, i am lost on how to do this and would be very grateful for any solutions, thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
would anyone know how to open the report directly into a pdf?
this example shows how you can export to PDF
once it's exported, then you can use System.Diagnostic.Process. Start("YOU R_PDF_FILE _PATH") to open this file using a pdf viewer.
- hope this helps
Dim exportPath As String = Me.txtPath.Text
If Not (exportPath Is Nothing OrElse exportPath.Length < 1) Then
Dim crDiskFileDestinationOptio ns As New DiskFileDestinationOptions ()
Dim crExportOptions As CrystalDecisions.Shared.Ex portOption s = rpt1.ExportOptions
rpt1.ExportOptions.ExportD estination Type = ExportDestinationType.Disk File
rpt1.ExportOptions.Destina tionOption s = crDiskFileDestinationOptio ns
crDiskFileDestinationOptio ns.DiskFil eName = exportPath
Select Case combobox.selectedIndex
Case 4
rpt1.ExportOptions.ExportF ormatType = ExportFormatType.RichText
Case 2
rpt1.ExportOptions.ExportF ormatType = ExportFormatType.PortableD ocFormat
Case 5
rpt1.ExportOptions.ExportF ormatType = ExportFormatType.WordForWi ndows
Case 1
rpt1.ExportOptions.ExportF ormatType = ExportFormatType.Excel
Case 6
rpt1.ExportOptions.ExportF ormatType = ExportFormatType.CrystalRe port
Case 3
Dim HTML40Formatopts As New HTMLFormatOptions()
With crExportOptions
.ExportDestinationType = ExportDestinationType.Disk File
.ExportFormatType = ExportFormatType.HTML40
End With
With HTML40Formatopts
.HTMLBaseFolderName = New System.IO.FileInfo(exportP ath).Direc toryName ' Foldername to place HTML files
.HTMLFileName = "Transaction Tracking System Report"
.HTMLEnableSeparatedPages = True
.HTMLHasPageNavigator = True
End With
crExportOptions.FormatOpti ons = HTML40Formatopts
End Select
Try
rpt1.Export()
MessageBox.Show("The export file(s) were successfully generated at the following location: " & vbCrLf & "Export Path: " & exportPath, "Completed Export", MessageBoxButtons.OK, MessageBoxIcon.Information )
Catch ex As Exception
MessageBox.Show("The following error occured while creating the specified report: " & vbCrLf & ex.Message & vbCrLf & "Export Path: " & exportPath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("You must provide a valid file name / path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
once it's exported, then you can use System.Diagnostic.Process.
- hope this helps
Dim exportPath As String = Me.txtPath.Text
If Not (exportPath Is Nothing OrElse exportPath.Length < 1) Then
Dim crDiskFileDestinationOptio
Dim crExportOptions As CrystalDecisions.Shared.Ex
rpt1.ExportOptions.ExportD
rpt1.ExportOptions.Destina
crDiskFileDestinationOptio
Select Case combobox.selectedIndex
Case 4
rpt1.ExportOptions.ExportF
Case 2
rpt1.ExportOptions.ExportF
Case 5
rpt1.ExportOptions.ExportF
Case 1
rpt1.ExportOptions.ExportF
Case 6
rpt1.ExportOptions.ExportF
Case 3
Dim HTML40Formatopts As New HTMLFormatOptions()
With crExportOptions
.ExportDestinationType = ExportDestinationType.Disk
.ExportFormatType = ExportFormatType.HTML40
End With
With HTML40Formatopts
.HTMLBaseFolderName = New System.IO.FileInfo(exportP
.HTMLFileName = "Transaction Tracking System Report"
.HTMLEnableSeparatedPages = True
.HTMLHasPageNavigator = True
End With
crExportOptions.FormatOpti
End Select
Try
rpt1.Export()
MessageBox.Show("The export file(s) were successfully generated at the following location: " & vbCrLf & "Export Path: " & exportPath, "Completed Export", MessageBoxButtons.OK, MessageBoxIcon.Information
Catch ex As Exception
MessageBox.Show("The following error occured while creating the specified report: " & vbCrLf & ex.Message & vbCrLf & "Export Path: " & exportPath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("You must provide a valid file name / path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
ASKER
but when the report opens it expands the table it is placed in. Can I set a size for the report to be so it will fit into the area of the page that I want it to take up.
i.e. the width be no more than 500