2017-09-19 67 views
0

我使用Stiwebviewer在Stimulsoft中做報告我在aspx文件中顯示它。現在我想設置用於導出的報告文件名,例如,當我將報告導出爲pdf ...默認名稱是報告(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(); 
    } 
相關問題