【Stimulsoft Reports.Net教程】使用DesignerFx
要添加Flash设计器,只需从Stimulsoft.Report.WebDesign 库添加StiWebDesignerFx组件即可。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Using_the_DesignerFx.Default" %> <%@ Register assembly="Stimulsoft.Report.WebDesign" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Using the DesignerFx</title> </head> <body> <form id="form1" runat="server"> <div> <cc1:StiWebDesignerFx ID="StiWebDesignerFx1" runat="server" /> </div> </form> </body> </html>
要打开报表模板以进行编辑,可以使用Page_Load事件。例如,创建新的报表对象,从文件加载SimpleList.mrt报表模板,从XML文件添加报表数据,并使用Design()方法调用Flash报表设计器。
protected void Page_Load(object sender, EventArgs e) { string appDirectory = HttpContext.Current.Server.MapPath(string.Empty); // Load report StiReport report = new StiReport(); report.Load(appDirectory + "\\Reports\\SimpleList.mrt"); // Assign data StiXmlDatabase database = new StiXmlDatabase("Demo", appDirectory + "\\Data\\Demo.xsd", appDirectory + "\\Data\\Demo.xml"); report.Dictionary.Databases.Add(database); report.Dictionary.Synchronize(); // Design report StiWebDesignerFx1.Design(report); }
示例代码的结果如下图所示: