Dinesh
Dinesh

Reputation: 35

How to load rpt file using c# in visual studio 2010?

Am using visual studio 2010 and trying to load a rpt file. I have used the following code.

ReportDocument rpt = new ReportDocument();
rpt.Load("E:\\Crystal reports docs\\Crystal Reports samples\\Crosstab report");

Then I used isLoaded() function to check whether it is loaded.

When I compile the program, it keeps on running.

Any suggestions???

Thanks in advance!!!!

Upvotes: 2

Views: 20359

Answers (2)

Linda.J
Linda.J

Reputation: 1

 ReportDocument reportDocument = new ReportDocument();
 //ADD
 string filePath = openFileDialog1.FileName;
 reportDocument.Load(filePath);
 crystalReportViewer1.ReportSource = reportDocument;

Upvotes: 0

Ramakrishna.p
Ramakrishna.p

Reputation: 1201

Here is the sample code how to load a crystal report (.rpt) file that is saved on a local drive instead of embedded. The advantage to this is the program does not need to be re-compiled each time a report is modified. Also, the .rpt can be upload from the application and stored in a database and then written to file. Do not embed the .rpt file when using this method.

using System;using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

namespace Report
{
    public partial class Report : Document    
    {
        public void ReportLoad()    
        {
            ReportDocument reportDocument = new ReportDocument();       
            string filePath = "C:\Projects\Application\Report\CrystalReport.rpt";                
            reportDocument.Load(filePath);  
            crystalReportViewer.ReportSource = reportDocument; 
        }   
    }
 }

Refer More about

http://scn.sap.com/thread/3312329

How do I load external Crystal Reports (2008) files in c#?

Upvotes: 5

Related Questions