Net-informations.com
SiteMap  | About    

Crystal Reports from XML File

In this section you can see , creating a Crystal Reports from XML file instead of database . This is very similer to creating Crystal Reports from database , the only difference is to sslect the data source as your XML file.

Here we are creating an XML file name is Product is XML file the same structure of the Product table in the sample Database Structure.

Download Product.XML

vb.net_crystal_report_xml_1.GIF

The basics of Crystal Reports creation provided in previous tutorials , if you dont have much knowledge in Crystal Reports , take a look at the tutorial step by step Crystal Report before start this section.

The change happen only from previous report , when you select Data for Crsyatl Report , you have to select Create New Connection - Database Files and select the XML file you want to generate Crystal Reports (In this case you select the Product.xml ).

vb.net_crystal_report_xml_2.GIF

Select all the fields from Product and click finish button

Now the designer part is over . Next step is to select the default form(Form1.vb) and add a Button and Crystal Reports Viewer to the Form.

Put the following vb.net source code in your form and run the program .




Imports CrystalDecisions.CrystalReports.Engine
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
	 ByVal e As System.EventArgs) Handles Button1.Click
        Dim cryRpt As New ReportDocument
        cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")
        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub
End Class

cryRpt.Load("PUT CRYSTAL REPORT PATH HERE\CrystalReport1.rpt")
The Crystal Report is in your project location, there you can see CrystalReport1.rpt . So give the full path name of report here.





net-informations.com (C) 2016    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.