[英]how to set export file name for a report in stimulsoft?
我通过使用Stiwebviewer在Stimulsoft中进行报告,并在aspx文件中显示该报告。 现在我想设置导出时使用的报告文件名,例如当我将报告导出为pdf时...默认名称为Report(1).pdf,然后将其更改为Sedi.pdf。
我尝试这样:
StiWebViewer1.ServerReportName = "Sedi";
但这没有用。
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();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.