Link to home
Start Free TrialLog in
Avatar of joeyton
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
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joeyton
joeyton

ASKER

Ok, It seems to work, thanks.

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
Avatar of joeyton

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("YOUR_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 crDiskFileDestinationOptions As New DiskFileDestinationOptions()
                    Dim crExportOptions As CrystalDecisions.Shared.ExportOptions = rpt1.ExportOptions

                    rpt1.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
                    rpt1.ExportOptions.DestinationOptions = crDiskFileDestinationOptions
                    crDiskFileDestinationOptions.DiskFileName = exportPath

                    Select Case combobox.selectedIndex
                        Case 4
                            rpt1.ExportOptions.ExportFormatType = ExportFormatType.RichText
                        Case 2
                            rpt1.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
                        Case 5
                            rpt1.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows
                        Case 1
                            rpt1.ExportOptions.ExportFormatType = ExportFormatType.Excel
                        Case 6
                            rpt1.ExportOptions.ExportFormatType = ExportFormatType.CrystalReport
                        Case 3
                            Dim HTML40Formatopts As New HTMLFormatOptions()
                            With crExportOptions
                                .ExportDestinationType = ExportDestinationType.DiskFile
                                .ExportFormatType = ExportFormatType.HTML40
                            End With

                            With HTML40Formatopts
                                .HTMLBaseFolderName = New System.IO.FileInfo(exportPath).DirectoryName   ' Foldername to place HTML files
                                .HTMLFileName = "Transaction Tracking System Report"
                                .HTMLEnableSeparatedPages = True
                                .HTMLHasPageNavigator = True
                            End With
                            crExportOptions.FormatOptions = 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