2017-09-19 8 views
0

Stiwebviewer를 사용하여 Stimulsoft에서 보고서를 만듭니다. aspx 파일에 표시합니다. 이제 예를 들어 보고서를 pdf로 내보낼 때 내보내기에 사용 된 보고서 파일 이름을 설정하려고합니다 ... 기본 이름은 Report (1) .pdf이고이를 Sedi.pdf로 변경하려고합니다.
나는이 시도 : stimulsoft에서 보고서의 내보내기 파일 이름을 설정하는 방법은 무엇입니까?

StiWebViewer1.ServerReportName = "Sedi";

는하지만 그것은 작동하지 않았다.

답변

0
string reportName = ""; 
protected void Page_Load(object sender, EventArgs e) 
    { 
     this.Mainreport = (StiReport)Session["SelectedReport"]; 
     this.reportName = (string)Session["ReportName"]; 
     StiWebViewer1.Report = this.Mainreport; 
     StiWebViewer1.DataBind(); 
     if (!IsPostBack) 
     { 
      string iQueryString = Request.QueryString["sti_StiWebViewer1_export"]; 
      if (iQueryString != null) this.SaveFile(iQueryString); 
     } 
    } 
    private void SaveFile(string iQueryString) 
    { 
     if (this.reportName == null) this.reportName = "Report"; 
     MemoryStream mes = new MemoryStream(); 
     HttpContext.Current.Response.Clear(); 
     switch (iQueryString) 
     { 
      #region Cases 
      case "SaveAdobePdf": 
       { 
        this.Mainreport.ExportDocument(StiExportFormat.Pdf, mes); 
        HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + this.reportName + ".Pdf"); 
       } 
       break; 
      case "SaveMicrosoftXps": 
       { 
        this.Mainreport.ExportDocument(StiExportFormat.Xps, mes); 
        HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + this.reportName + ".Xps"); 
       } 
       break; 
       #endregion 
     } 
     mes.WriteTo(Response.OutputStream); 
     HttpContext.Current.Response.End(); 
     mes.Close(); 
    }