如何在 stimulsoft 中为报告设置导出文件名?
how to set export file name for a report in stimulsoft?
我使用 Stiwebviewer 在 Stimulsoft 中制作了一份报告,我将其显示在 aspx 文件中。现在我想设置导出时使用的报告文件名,例如当我将报告导出为 pdf 时...默认名称是 Report(1).pdf.And 我想将其更改为 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();
}
我使用 Stiwebviewer 在 Stimulsoft 中制作了一份报告,我将其显示在 aspx 文件中。现在我想设置导出时使用的报告文件名,例如当我将报告导出为 pdf 时...默认名称是 Report(1).pdf.And 我想将其更改为 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();
}