Solved

C# Crystal Reports

Posted on 2004-04-15
6
217 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:joeyton
  • 2
6 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 125 total points
Comment Utility
remember to set the table on the .Fill() to the same table name you used in the report.
0
 
LVL 1

Author Comment

by:joeyton
Comment Utility
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
0
 
LVL 1

Author Comment

by:joeyton
Comment Utility
would anyone know how to open the report directly into a pdf?
0
 
LVL 9

Expert Comment

by:malharone
Comment Utility
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
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now