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!!!!

有帮助吗?

解决方案

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#?

其他提示

 ReportDocument reportDocument = new ReportDocument();
 //ADD
 string filePath = openFileDialog1.FileName;
 reportDocument.Load(filePath);
 crystalReportViewer1.ReportSource = reportDocument;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top