Stimulsoft Reports.Web打印报错

偉Vae 2017-08-01 10:31:29
哪位大神用过Stimulsoft Reports.Web



点击打印的时候一直提示错误,应该怎么处理呢?
代码:
前端:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="report.aspx.cs" Inherits="WeiXinTest.Content.page.report" %>
<%@ Register Namespace="Stimulsoft.Report.Web" TagPrefix="cc1" Assembly="Stimulsoft.Report.Web, Version=2013.1.1600.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a"%>
<%@ Register Namespace="Stimulsoft.Report.Web" TagPrefix="cc2" Assembly="Stimulsoft.Report.WebDesign, Version=2013.1.1600.0, Culture=neutral, PublicKeyToken=ebe6666cba19647a"%>

<!doctype html>
<html>
<head runat="server">
<title></title>
</head>
<body style="background-color: #e8e8e8">
<form id="form1" runat="server">
<div style="width: 960px;margin: 0 auto;">
<cc1:StiWebViewer ID="StiWebViewer1" runat="server" GlobalizationFile="/Content/page/reports/Localization/zh-CHS.xml" ShowDesignButton="True" onreportdesign="StiWebViewer1_ReportDesign" Theme="Office2010" BackColor="#e8e8e8"/>
<cc2:StiWebDesigner ID="StiWebDesigner1" runat="server" LocalizationDirectory="/Content/page/reports/Localization/" Localization="zh-CHS" onsavereport="StiWebDesigner1_SaveReport" />
</div>
</form>
</body>
</html>

后端:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Stimulsoft.Report;

namespace WeiXinTest.Content.page
{
public partial class report : System.Web.UI.Page
{
/// <summary>
/// 将获取的报表放在阅读器中显示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
StiWebViewer1.Report = GetReport();
}

/// <summary>
/// 编辑报表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void StiWebViewer1_ReportDesign(object sender, EventArgs e)
{
StiWebDesigner1.Design(GetReport());
}

/// <summary>
/// 保存报表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void StiWebDesigner1_SaveReport(object sender, Stimulsoft.Report.Web.StiWebDesigner.StiSaveReportEventArgs e)
{
var report = e.Report;
report.Save(GetReportPath());
}

/// <summary>
/// 获取报表
/// </summary>
/// <returns></returns>
private StiReport GetReport()
{
var report = new StiReport();
//根据路径加载报表文件
report.Load(GetReportPath());
//动态改变数据库连接
ChangeConnectString(report);
//设置参数等
report.Compile();
SetReportParamaters(report);

return report;
}

private void SetReportParamaters(StiReport report)
{
var dataSource = report.CompiledReport.DataSources;
foreach (Stimulsoft.Report.Dictionary.StiDataSource ds in dataSource)
{
var param = Request.QueryString;
foreach (string key in param.Keys)
{
if (!ds.Parameters.Contains(key)) continue;
var p = ds.Parameters[key];
var v = param[key];
p.ParameterValue = v;
}
}
}

private string GetReportPath()
{
var path = String.Format("~/Areas/{0}/Reports/{1}.mrt", Request["area"], Request["rpt"]);
path = Server.MapPath(path);
if (!System.IO.File.Exists(path))
//如果报表文件不存在,返回默认的报表文件
path = Server.MapPath("~/Content/page/reports/helloworld.mrt");
return path;
}

private void ChangeConnectString(StiReport report)
{
foreach (Stimulsoft.Report.Dictionary.StiSqlDatabase item in report.Dictionary.Databases)
{
var prefix = item.Name.Split('_')[0];
item.ConnectionString = ConfigurationManager.ConnectionStrings["sqlConnection"].ConnectionString;
}
}
}
}
...全文
750 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sdk大全 2017-12-15
  • 打赏
  • 举报
回复
版本太低了,有BUG,更新版本吧,VX/QQ: 578867473

8,833

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 组件/控件开发
社区管理员
  • 组件/控件开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧