This sample project demonstrates a runtime dashboard creation.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Runtime_Dashboard_Creation.Default" %>
<%@ Register assembly="Stimulsoft.Report.Web" namespace="Stimulsoft.Report.Web" tagprefix="cc1" %>
<%@ Register assembly="Stimulsoft.Report.WebDesign" namespace="Stimulsoft.Report.Web" tagprefix="cc2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<br />
<asp:Button ID="ButtonShow" runat="server" Text="Show Dashboard" OnClick="ButtonShow_Click" />
<asp:Button ID="ButtonEdit" runat="server" Text="Edit Dashboard" OnClick="ButtonEdit_Click" />
<asp:Button ID="ButtonExport" runat="server" Text="Export to Excel" OnClick="ButtonExport_Click" />
<cc1:StiWebViewer ID="StiWebViewer1" runat="server" FullScreenMode="true" Visible="false" />
<cc1:StiWebDesigner ID="StiWebDesigner1" runat="server" Visible="false" />
</form>
</body>
</html>
First, use
Load()
method to load dashboard template:
private StiReport GetTemplate()
{
var report = StiReport.CreateNewDashboard();
report.Load(Server.MapPath("Dashboards/DashboardChristmas.mrt"));
return report;
}
...
After that, use
StiReportResponse
methods to export template to neccessary format:
...
protected void ButtonExportPdf_Click(object sender, EventArgs e)
{
var report = GetTemplate();
StiReportResponse.ResponseAsPdf(report);
}
protected void ButtonExportExcel_Click(object sender, EventArgs e)
{
var report = GetTemplate();
StiReportResponse.ResponseAsExcel2007(report);
}
protected void ButtonExportImage_Click(object sender, EventArgs e)
{
var report = GetTemplate();
StiReportResponse.ResponseAsPng(report);
}
На скриншоте ниже Вы можете увидеть результат выполнения данного кода: