下載Stimulsoft Reports.Net最新版本download
此示例項目演示瞭如何在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;
}
示例代碼的結果如下圖所示: