2009-03-11 2 views
1

ASP.NET 페이지에서 Crystal Report Viewer (CRV)의 보고서를 볼 때 보고서를 PDF로 내보낼 수 있습니다). 내보내기의 기본 파일 이름은 CRV의 ID입니다.Crystal 보고서 뷰어에서 기본 내보내기 이름을 설정하는 방법

기본 이름을 보고서의 매개 변수를 기반으로하는 것으로 설정하고 싶습니다. (예 : "Sales for 2008").

페이지에 링크를 추가 할 수 있다는 것을 알고 코드에서 PDF를 생성하고 브라우저에서 스트림을 생성하는 솔루션을 코딩 할 수는 있지만 어떻게해야할까요? Crystal Reports에서이 탄생.

+0

보고서의 DocumentName 속성을 믿습니다. – sam

답변

0

Visual Studio 2008을 사용하여 보고서를 만드는 경우 DefaultName 속성을 추가하기 위해 만든 ReportClass를 편집 할 수 있습니다.

3
// You could pass the parameters to the web page 
// where you have theCrystalReportViewer control 
protected void Page_Load(object sender, EventArgs e) 
{ 
    string reportId = Request["rid"]; 
    string reportTitle = Request["rtitle"]; 

    ReportDocument reportDocument = HttpContext.Current.Session[reportId] as ReportDocument; 
    this.CommonCrystalReportViewer.ReportSource = reportDocument; 
    this.CommonCrystalReportViewer.DataBind(); 

    // Set the default export file name for the report. 
    this.CommonCrystalReportViewer.ID = reportTitle; 
} 
0

기본적으로 ReportViewer 클래스 대신 ReportExporter 클래스를 사용하지만 더 이상 지원되지 않습니다. 세 번째 부분도 비슷합니다.

는이 코드 샘플을 사용

string myParamName="XXX"; 
object myParamValue; 
foreach (ParameterField field in reportDocument.ParameterFields) 
      { 
       if (string.Compare(field.Name.TrimStart('@'), myParamName, true) == 0) 
        myParamValue= field.CurrentValues; 
      } 

수출 보고서 이름이 필요 사용 (당신이 다른 곳 세션, QueryString을 또는에서 이미이없는 경우) 보고서에서

가져 오기 매개 변수 값을

string myReportName = "sales for " + myParamValue.ToString() + ".pdf"; 
try 
    { 
    reportDocument.ExportToHttpResponse( 
       ExportFormatType.PortableDocFormat 
       ,Response, true, myReportName); 
    } 
catch (System.Threading.ThreadAbortException) 
    { 
     //System.Threading.ThreadAbortException is thrown 
     //because, Response.End is called internally in ExportToHttpResponse method: 
    } 
-1
protected void Page_Init(object sender, EventArgs e) { 
    ... 
    // Set the default export file name for the report. 
    this.mainReportViewer.ID = reportTitle; 
    ... 
} 

변경해야합니다. reportViewer 의기능이 작동하지 않습니다.

관련 문제