·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> visual studio 2010 自带reporting报表本地加载的使用

visual studio 2010 自带reporting报表本地加载的使用

作者:佚名      ASP.NET网站开发编辑:admin      更新时间:2022-07-23

visual studio 2010 自带reporting报表本地加载的使用

在这家公司时间不长,接触都是之前没玩过的东东,先是工作流引擎和各种邮件短信的审核信息,后又是部署reporting服务器。

reporting服务部署就不在这多说,在vs2010里面是自带了reporting报表的直接添加就可以使用。如图

这是一个空白的模板。这时模板已有了就差数据了在新加一个数据集DataSet

数据集有了模板有了就回到reporting模板页在这上面设计格式了,在空白处 右键-插入-表(也可以是其他图表之类)选择数据源

此时的报表模板就和绑定web控件一样设定对于字段

到这模板设定就完成了。接着去写对应的加载页面了aspx的html如下

<rsweb:ReportViewer ID="rvReport" runat="server" Font-Names="Verdana"         Font-Size="8pt"  WaitMessageFont-Size="14pt"  InteractiveDeviceInfos="(集合)" WaitMessageFont-Names="Verdana"          Width="100%" Height="90%">        <LocalReport ReportPath="ReportFiles\RepairCountReport.rdlc">          <DataSources>            <rsweb:ReportDataSource  DataSourceId="ObjectDataSource1" Name="DataSet1"/>          </DataSources>        </LocalReport>    </rsweb:ReportViewer>    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server">    </asp:ObjectDataSource>

在cs文件加载数据代码如下

 PRivate void InitDataGrid()        {            string betweenBegin = BetweenBegin.Value;            string betweenEnd = BetweenEnd.Value;            if (string.IsNullOrWhiteSpace(betweenBegin) || string.IsNullOrWhiteSpace(betweenEnd))            {                PromptHelper.ShowMessageJbox("温馨提示", "请输入查询区间", this);                return;            }            //默认是选中即油站名称进行分组            string groupbyValue = "";            if (ckOuName.Checked)            {                groupbyValue = "1";            }            else            {                groupbyValue = RadioButtonList1.SelectedValue;            }            sqlWhere = "  and (T1.ActualFinishDate BETWEEN '" + betweenBegin + "' AND '" + betweenEnd + "')  ";           string ouName=OUName.Value;           if (!string.IsNullOrWhiteSpace(ouName) && ouName != "油站名称")           {               sqlWhere += " and T3.OUName like '%" + ouName + "%'";           }            //先获取数据            SqlHelper helper = new SqlHelper();            SqlParameter[] par = new SqlParameter[]{                new SqlParameter("@sqlWhere",SqlDbType.VarChar,1000),                new SqlParameter("@groupby",SqlDbType.VarChar,2)            };            par[0].Value = sqlWhere;            par[1].Value = groupbyValue;            DataSet DataSet1 = helper.ExecuteDataSet(CommandType.StoredProcedure, "proc_RepairCountReport", par);            this.rvReport.Visible = true;            this.rvReport.LocalReport.DataSources.Clear();            ObjectDataSource1.SelectParameters.Clear();            ObjectDataSource1.SelectParameters.Add("sqlWhere", sqlWhere);            this.rvReport.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", DataSet1.Tables[0]));            this.rvReport.LocalReport.Refresh();        }

  到这就算整个报表都已经做完了看看效果吧