【Stimulsoft Reports.Net教程】在ViewerFx中显示报表

下载Stimulsoft Reports.Net最新版本

此示例项目演示了如何在ASPX页面上添加Flash查看器并显示简单报表。要添加Flash查看器,只需从Stimulsoft.Report.Web库中添加StiWebViewerFx组件即可。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Show_Report_in_the_ViewerFx.Default" %>
<%@ Register assembly="Stimulsoft.Report.Web" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %>
 
<!DOCTYPE html>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Show Report in the ViewerFx</title>
</head>
<body>
    <form id="form1" runat="server">
        <cc1:StiWebViewerFx ID="StiWebViewerFx1" runat="server"
                Width="100%" Height="800px"
                OnGetReport="StiWebViewerFx1_GetReport" />
    </form>
</body>
</html>

要显示报表,您应该添加OnGetReport事件,您需要在该事件中加载报表,并在需要时注册数据。

protected void StiWebViewerFx1_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 Reports.Net教程】在ViewerFx中显示报表

查看原文,下载示例