Stimulsoft.Report 2、 web报表的使用

本文介绍如何使用Stimulsoft Report Web组件在ASP.NET项目中实现报表的设计与展示,包括添加必要的引用、配置报表控件及实现设计与保存功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Stimulsoft.Report web报表的使用,有需要的朋友可以参考下。

1、先用报表设计工具设计报表Report1.mrt(具体参照Stimulsoft_Reports 1. 报表制作http://blog.youkuaiyun.com/qq_31971935/article/details/50681730

2、在项目中添加对Stimulsoft.Base.dll、Stimulsoft.Report.dll、Stimulsoft.Report.Web.dll、Stimulsoft.Report.WebDesign.dll的引用

3、在aspx页面中注册控件

<%@ register Namespace="Stimulsoft.Report.Web" TagPrefix="cc1"   Assembly="Stimulsoft.Report.Web"%>
<%@ register Namespace="Stimulsoft.Report.Web" TagPrefix="cc2" Assembly="Stimulsoft.Report.WebDesign"%>

注:注册控件方式:
<%@ Register TagPrefix=”abc” Namespace=”空间名.类名” Assembly=”空间名.类名” %>
4、aspx页面中放置报表显示控件和报表设计控件

<cc1:StiWebViewer ID="StiWebViewer1" runat="server" GlobalizationFile="/reports/Localization/zh-CHS.xml" ShowDesignButton="True" onreportdesign="StiWebViewer1_ReportDesign" Theme="Office2010" BackColor="#e8e8e8"/>

<cc2:StiWebDesigner ID="StiWebDesigner1" runat="server" LocalizationDirectory="/reports/Localization/" Localization="zh-CHS"onsavereport="StiWebDesigner1_SaveReport" />

注:设置中文格式的文件夹应放置在项目的bin下面即可。

5、在代码文件中引用
using Stimulsoft.Report;

6、在Page_Load中

string filepath = Server.MapPath("~/Report1.mrt");
StiReport stireport = new StiReport();
stireport.Load(filepath);
stireport.Compile();
StiWebViewer1.Report = stireport;

7、在StiWebViewer1的ReportDesign中

string filepath = Server.MapPath("~/Report1.mrt");
StiReport stireport = new StiReport();
stireport.Load(filepath);
stireport.Compile();
StiWebDesigner1.Design(stireport);

8、在StiWebDesigner1的SaveReport中

var report = e.Report;
string filepath = Server.MapPath("~/Report1.mrt");
report.Save(filepath);

aspx页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Stimulsoft_Reports.WebForm1" %>
<!DOCTYPE html>
<%@ register Namespace="Stimulsoft.Report.Web" TagPrefix="cc1"   Assembly="Stimulsoft.Report.Web"%>
<%@ register Namespace="Stimulsoft.Report.Web" TagPrefix="cc2" Assembly="Stimulsoft.Report.WebDesign"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <cc1:StiWebViewer ID="StiWebViewer1" runat="server" GlobalizationFile="/Content/page/reports/Localization/zh-CHS.xml" ShowDesignButton="True" onreportdesign="StiWebViewer1_ReportDesign" Theme="Office2010" BackColor="#e8e8e8"/>

        <cc2:StiWebDesigner ID="StiWebDesigner1" runat="server" LocalizationDirectory="/Content/page/reports/Localization/" Localization="zh-CHS"  onsavereport="StiWebDesigner1_SaveReport" />
    </div>
    </form>
</body>
</html>

aspx.cs后台代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Stimulsoft.Report;
namespace Stimulsoft_Reports
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string filepath = Server.MapPath("~/Report1.mrt");
            StiReport stireport = new StiReport();
            stireport.Load(filepath);
            stireport.Compile();
            StiWebViewer1.Report = stireport;
        }

        protected void StiWebViewer1_ReportDesign(object sender, Stimulsoft.Report.Web.StiReportDesignEventArgs e)
        {
            string filepath = Server.MapPath("~/Report1.mrt");
            StiReport stireport = new StiReport();
            stireport.Load(filepath);
            stireport.Compile();
            StiWebDesigner1.Design(stireport);
        }

        protected void StiWebDesigner1_SaveReport(object sender, Stimulsoft.Report.Web.StiWebDesigner.StiSaveReportEventArgs e)
        {
            var report = e.Report;
            string filepath = Server.MapPath("~/Report1.mrt");
            report.Save(filepath);
        }
    }
}

项目文件结构图:

这里写图片描述

运行后效果:
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值