2013-08-20 5 views
1

Visual Studio 2010을 사용하고 rpt 파일을로드하려고합니다. 다음 코드를 사용했습니다.Visual Studio 2010에서 C#을 사용하여 rpt 파일을로드하는 방법은 무엇입니까?

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

그런 다음이 기능이로드되었는지 확인하려면 isLoaded() 함수를 사용했습니다.

프로그램을 컴파일하면 실행이 계속됩니다.

제안 사항 ???

미리 감사드립니다 !!!!

+0

요 .... u는 더 구체적 일 수있다 상세 정보를 참조하십시오? – Dinesh

답변

4

다음은 포함되지 않고 로컬 드라이브에 저장된 크리스탈 보고서 (.rpt) 파일을로드하는 샘플 코드입니다. 이점은 보고서가 수정 될 때마다 프로그램을 다시 컴파일 할 필요가 없다는 것입니다. 또한 .rpt는 응용 프로그램에서 업로드하여 데이터베이스에 저장 한 다음 파일에 쓸 수 있습니다. 이 방법을 사용할 때 .rpt 파일을 포함하지 마십시오.

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; 
     } 
    } 
} 

얻을 어차피

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

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

+0

감사합니다. ramakrishna. 나는 당신이 말한 것과 똑같은 짓을했으나 crystalReportViewer라는 이름의 오류가 컨텍스트에 존재하지 않습니다. – Dinesh

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