您的位置:首页 > 其它

水晶报表初体验(Visual Studio 2010)

2015-12-01 21:47 393 查看
安装水晶报表后如下使用;

配置rpt文件,如图



 

前台(Asp.net页面):

<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

<CR:CrystalReportViewer ID="ReTransport" runat="server" AutoDataBind="true" />


 

后台:

public void GetList()
{
ReportDocument doc = new ReportDocument();
// rpt文件路径
doc.Load(Server.MapPath("/Cry/CrystalInSchoolInfo.rpt"));
ReTransport.ToolPanelView = ToolPanelViewType.None;
Maticsoft.BLL.list.Lists pro = new Maticsoft.BLL.list.Lists();
if (Session["CrystalData"]!=null)
{
//配置数据源dataset
doc.SetDataSource((DataTable)Session["CrystalData"]);
this.ReTransport.ReportSource = doc;
this.ReTransport.DataBind();
}
else
{
HttpContext.Current.Response.Write("<script>alert('连接超时,请刷新!');window.location.href=document.referrer;</script>");
}
}


使用注意:rpt文件配置过程中,页面长度代表一列,若拉的太长,会默认增加到下一页,导致误判为无法遍历数据的错觉

关于更高级的内嵌报表之类的,我就没有使用过了,以后边用边学吧。

最后贴上Visual Studio 2010的水晶报表安装包下载地址:http://yunpan.cn/QC9fWzZdj64ER(提取码:a7b9)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: