发布时间 : 2018-10-26 10:47:14.000|阅读 416 次
概述:此示例项目演示了如何在ASPX页面上添加HTML5查看器并显示简单报表。
相关链接:
此示例项目演示了如何在ASPX页面上添加HTML5查看器并显示简单报表。要添加查看器,只需从Stimulsoft.Report.Web库中添加StiWebViewer组件即可。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Show_Report_in_the_Viewer.Default" %>
<%@ Register assembly="Stimulsoft.Report.Web" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %>
 
<!DOCTYPE html>
<html>
<head runat="server">
    <title>Show report in the Viewer</title>
</head>
<body>
    <form id="form1" runat="server">
        <cc1:StiWebViewer ID="StiWebViewer1" runat="server" 
            OnGetReport="StiWebViewer1_GetReport" />
    </form>
</body>
</html>
要显示报表,您应该添加OnGetReport事件,您需要在该事件中加载报表,并在需要时注册数据。
protected void StiWebViewer1_GetReport(object sender, Stimulsoft.Report.Web.StiReportDataEventArgs e)
{
    string reportPath = Server.MapPath("Reports/SimpleList.mrt");
    StiReport report = new StiReport();
    report.Load(reportPath);
 
    string dataPath = Server.MapPath("Data/Demo.xml");
    DataSet data = new DataSet();
    data.ReadXml(dataPath);
    report.RegData(data);
 
    e.Report = report;
}
示例代码的结果如下图所示:

购买Stimulsoft正版授权,请点击“咨询在线客服”哟!
渝ICP备12000582号-15/渝公网安备 50010702501010号