Stimulsoft Reports.web, a report tool that allows you to edit reports directly in the Web
Web Project Technical Framework Mvc4+easyui+knockoutjs
1. Adding references to the project
Stimulsoft.Base.dll,
Stimulsoft.Report.dll,
Stimulsoft.Report.Web.dll,
Stimulsoft.Report.WebDesign.dll
2. Define template file: Create a new Web Form file report.aspx
Front Code:
<%@ Page Language="C #"AutoEventWireup="true"codebehind="Report.aspx.cs"Inherits="PE. IEM. Web.report" %><%@ Register Namespace="Stimulsoft.Report.Web"TagPrefix="CC1"Assembly="Stimulsoft.Report.Web, version=2012.3.1500.0, culture=neutral, Publickeytoken=096a9279a87304f1"%><%@ Register Namespace="Stimulsoft.Report.Web"TagPrefix="CC2"Assembly="Stimulsoft.Report.WebDesign, version=2012.3.1500.0, culture=neutral, Publickeytoken=096a9279a87304f1"%><!DOCTYPE HTML><HTML> <Headrunat= "Server"> <title></title> </Head> <Bodystyle= "Background-color: #e8e8e8"> <formID= "Form1"runat= "Server"> <Divstyle= "width:960px;margin:0 auto;"> <Cc1:stiwebviewerID= "StiWebViewer1"runat= "Server"Globalizationfile= "/content/page/reports/localization/zh-chs.xml"Showdesignbutton= "True"onreportdesign= "Stiwebviewer1_reportdesign"Theme= "Office2010"BackColor= "#e8e8e8"/> <Cc2:stiwebdesignerID= "StiWebDesigner1"runat= "Server"localizationdirectory= "/content/page/reports/localization/"Localization= "Zh-chs"Onsavereport= "Stiwebdesigner1_savereport" /> </Div> </form> </Body></HTML>
Background code:
usingSystem;usingSystem.Collections.Generic;usingSystem.Configuration;usingSystem.IO;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingStimulsoft.report;namespacePE. IEM. web{ Public Partial classReport:System.Web.UI.Page {/// <summary> ///put the obtained report in the reader display/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> protected voidPage_Load (Objectsender, EventArgs e) {Stiwebviewer1.report=GetReport (); } /// <summary> ///Edit Report/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> protected voidStiwebviewer1_reportdesign (Objectsender, EventArgs e) {stiwebdesigner1.design (GetReport ()); } /// <summary> ///Save Report/// </summary> /// <param name= "Sender" ></param> /// <param name= "E" ></param> protected voidStiwebdesigner1_savereport (Objectsender, Stimulsoft.Report.Web.StiWebDesigner.StiSaveReportEventArgs e) { varreport =E.report; Report. Save (Getreportpath ()); } /// <summary> ///Get reports/// </summary> /// <returns></returns> PrivateStireport GetReport () {varreport =NewStireport (); //load report files based on pathReport . Load (Getreportpath ()); //dynamically changing database connectionschangeconnectstring (report); //setting parameters, etc.Report.compile (); Setreportparamaters (report); returnReport ; } Private voidsetreportparamaters (Stireport report) { varDataSource =report.CompiledReport.DataSources; foreach(Stimulsoft.Report.Dictionary.StiDataSource DSinchDataSource) { varparam =Request.QueryString; foreach(stringKeyinchparam. Keys) {if(!ds. Parameters.contains (Key))Continue; varp =ds. Parameters[key]; varv =Param[key]; P.parametervalue=v; } } } Private stringGetreportpath () {varPath = String.Format ("~/AREAS/{0}/REPORTS/{1}.MRT", request[" Area"], request["rpt"]); Path=Server.MapPath (path); if(!System.IO.File.Exists (path))
If the report file does not exist, return to the default report file path= Server.MapPath ("~/CONTENT/PAGE/REPORTS/HELLOWORLD.MRT"); returnpath; } Private voidchangeconnectstring (Stireport report) { foreach(Stimulsoft.Report.Dictionary.StiSqlDatabase IteminchReport . dictionary.databases) {varprefix = Item. Name.split ('_')[0]; Item. ConnectionString= configurationmanager.connectionstrings["SqlConnection"]. ConnectionString; } } }}
is to put the reader and the editor in the template
3.js call: Because the template file is the root directory, so directly access and pass 2 parameters, according to the parameters passed to specify the report file
This function () {
Parent.wrapper.addTab.apply (this,{' Print Report ', '/report?area=xx&rpt=helloworld ', ' Icon-printer_color '});
};
4. Effect display
Web Reporting tools Stimulsoft Reports.web for use in MVC projects