Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse Crystal Reports to build a PDF file in Visual Basic 2005
DescriptionThis example shows how to use Crystal Reports to build a PDF file in Visual Basic 2005.
KeywordsCrystal Reports, PDF file, report, VB.NET, Visual Basic 2005
CategoriesFiles and Directories, Miscellany
 
First define a DataSet at design time. See the HowTo Define a DataSet at design time in Visual Basic 2005 for details.

Next add a new Crystal Report object to the project:

  1. Open the Project menu and select the Add New Item command.
  2. Select Crystal Report, give it a good name (such as AppointmentsReport.rpt), and click Add.
  3. Create a standard report by using the Report Wizard. On the wizard's Data page, open the "Project Data" entry and expand its "ADO.NET DataSets" item. Open the DataSet you created, select the table you want, and click the ">" button to select it as a data source for the report. Click Next.
  4. Use the ">>" button to add all of the table's fields to the report.
  5. Use the wizard's other pages to provide other report features such as Group By.
  6. When you finish, the wizard will create a report containing all of the fields in a simple layout.

    You can modify the report if you wish to make it look nicer.

    The example program uses the following code to populate a DataSet, attach it to the report, and save the report in a PDF file.

 
' Make a DataSet and add some records to it.
Dim ds As New PeopleDataSet()
ds.dtPeople.Rows.Add("Alice", "Archer", "111 Ash Ave", _
    "Ashland", "KY", "11111", "111-111-1111")
ds.dtPeople.Rows.Add("Ben", "Butter", "222 Beach Blvd", _
    "Bend", "OR", "22222", "222-222-2222")
ds.dtPeople.Rows.Add("Cindy", "Concert", "333 Cedar Ct", _
    "Cinderblock", "NV", "33333", "333-3333")

' Create a new report and attach it to the DataSet.
Dim rpt As New AppointmentsReport()
rpt.SetDataSource(ds)

' Save the report in PDF format.
rpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, _
    "test.pdf")

' Clean up.
rpt.Dispose()
ds.Dispose()
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated