博计报表中如何用define发布报表

在博计报表中支持多种方式发布报表,像我们常用的文件的方式,defineBean方式和ReportBean的方式.

下面我们就介绍一下如何用defineBean的方式发布报表.

第一步:写一个计算报表defineBean的CS类:

using System;
using System.IO;
using System.Data;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Web.Hosting;

using com.runqian.report.usermodel;
using com.runqian.report.graph;
using com.runqian.report.cellset;

public partial class reportMES_frmGraphShow : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

//取得报表名,报表根目录
string reportName = “”;

String reportFileHome = com.runqian.report.usermodel.Context.ReportConfig.ReportFileHome;


string beanName = “aa”;

//获取报表定义
ReportDefine rd = new ReportDefine(“C://reportToHtml.raq”);

//把rd放入HttpContext中
Context.Items[beanName] = rd;

//设置参数及其他公共操作


HtmlTag_1.BeanName = beanName;

}


第二步:我们设计一个aspx用define的方式发布报表:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”frmGraphShow.aspx.cs” Inherits=”reportMES_frmGraphShow” %>
<%@ Register Assembly=”report35net” Namespace=”com.runqian.report.tag” TagPrefix=”rq” %>

<html>
<head id=”Head1″ runat=”server”>
<title runat=”server” id=”tlt”>图表</title>

</head>
<body leftmargin=”0″ topmargin=”0″ rightmargin=”0″ bottomMargin=”0″>


<table cellspacing=”0″ cellpadding=”0″ border=”0″>
<tr><td>
<rq:HtmlTag
ID=”HtmlTag_1″
Name=”report1″
SrcType=”defineBean”
runat=”server”
needScroll=”yes”
FuncBarLocation = “top”
needPrint=”yes”
NeedSaveAsExcel=”yes”
NeedSaveAsPdf=”yes”
/>
</td></tr>
</table>
</body>
</html>

这样我们就可以用defineBean的方式发布报表了,用defineBean的方式发布报表的好处就是可以动态的修改报表定义,从而满足不同的多样的需求.