1. 程式人生 > >【Stimulsoft Reports.Net教程】帶滾動條的Web檢視器

【Stimulsoft Reports.Net教程】帶滾動條的Web檢視器

下載Stimulsoft Reports.Net最新版本

預設情況下,檢視器將其自身大小調整為報表的大小。如果要顯示具有指定寬度和高度的檢視器,則可能存在檢視報表的整個頁面或頁面的問題。為此,它是一種帶滾動條的特殊模式。

要新增帶有滾動條的Web檢視器,只需設定檢視器元件的寬度和高度,並將特殊的ScrollbarsMode屬性設定為True即可。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Web_Viewer_with_Scroll_Bars.Default" %>
<%@ Register assembly="Stimulsoft.Report.Web" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %>
 
<!DOCTYPE html>
<html>
<head runat="server">
    <title>Web Viewer with Scroll Bars</title>
</head>
<body>
    <form id="form1" runat="server">
        <cc1:StiWebViewer ID="StiWebViewer1" runat="server" 
            Width="800px" Height="500px" ScrollbarsMode="true"
            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

檢視原文,下載示例