Back to Devexpress

CustomExportWebEventArgs.Report Property

dashboard-devexpress-dot-dashboardweb-dot-customexportwebeventargs.md

latest13.0 KB
Original Source

CustomExportWebEventArgs.Report Property

Gets the underlying report of the exported document.

Namespace : DevExpress.DashboardWeb

Assembly : DevExpress.Dashboard.v25.2.Web.dll

NuGet Package : DevExpress.Web.Dashboard.Common

Declaration

csharp
public XtraReport Report { get; }
vb
Public ReadOnly Property Report As XtraReport

Property Value

TypeDescription
XtraReport

An XtraReport object that is the underlying report of the exported document.

|

Remarks

You can use the Report parameter to customize the underlying report. When you handle the ASPxDashboard.CustomExport event, you can obtain the following information:

Note

Note that a reference to the DevExpress.XtraReports.v25.2.dll assembly should be added to the project to allow users to customize the underlying report (CustomExportWebEventArgs.Report).

Example

The following example shows how to specify header and footer content of an exported dashboard. The ASPxDashboard.CustomExport event provides access to the underlying report created for the exported document.

View Example

aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebDashboard_CustomExport.Default" %>

<%@ Register Assembly="DevExpress.Dashboard.v16.2.Web, Version=16.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0;">
        <dx:ASPxDashboard ID="ASPxDashboard1" runat="server" Width="100%" Height="100%"
            AllowExportDashboardItems="True"
            OnConfigureDataConnection="ASPxDashboard1_ConfigureDataConnection"            
            OnCustomExport="ASPxDashboard1_CustomExport">
        </dx:ASPxDashboard>
    </div>
    </form>
</body>
</html>
csharp
using System;
using System.Web.Hosting;
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;

namespace WebDashboard_CustomExport
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DashboardFileStorage dashboardFileStorage = new DashboardFileStorage("~/App_Data/Dashboards");
            ASPxDashboard1.SetDashboardStorage(dashboardFileStorage);

            DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "access97Connection");
            SelectQuery query = SelectQueryFluentBuilder
                .AddTable("SalesPerson")
                .SelectAllColumns()
                .Build("Sales Person");
            sqlDataSource.Queries.Add(query);

            DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
            dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());
            ASPxDashboard1.SetDataSourceStorage(dataSourceStorage);
        }

        protected void ASPxDashboard1_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
            if (e.ConnectionName == "access97Connection") {
                Access97ConnectionParameters access97Params = new Access97ConnectionParameters();
                access97Params.FileName = HostingEnvironment.MapPath(@"~/App_Data/nwind.mdb");
                e.ConnectionParameters = access97Params;
            }
        }
        protected void ASPxDashboard1_CustomExport(object sender, CustomExportWebEventArgs e)
        {
            XtraReport report = e.Report as XtraReport;
            PageHeaderBand headerBand = new PageHeaderBand();
            report.Bands.Add(headerBand);

            XRPictureBox icon = new XRPictureBox();
            icon.ImageUrl = @"~/App_Data/Images/dxlogo.png";
            icon.HeightF = 50;
            icon.WidthF = 300;
            headerBand.Controls.Add(icon);

            XRLabel customHeader = new XRLabel();
            customHeader.Text = "Additioanl Header Text";
            customHeader.LeftF = 300;
            customHeader.WidthF = 300;
            headerBand.Controls.Add(customHeader);         

            XRPageInfo dateInfo = new XRPageInfo();
            dateInfo.PageInfo = PageInfo.DateTime;
            dateInfo.Format = "Created at {0:h:mm tt dd MMMM yyyy}";
            dateInfo.TopF = 100;
            dateInfo.WidthF = 200;
            headerBand.Controls.Add(dateInfo);

            XRPageInfo userInfo = new XRPageInfo();
            userInfo.PageInfo = PageInfo.UserName;
            userInfo.Format = "Current User: {0}";
            userInfo.TopF = 100;
            userInfo.LeftF = 250;
            userInfo.WidthF = 200;
            headerBand.Controls.Add(userInfo);

            PageFooterBand footerBand = new PageFooterBand();
            report.Bands.Add(footerBand);
            XRPageInfo pageInfo = new XRPageInfo();
            pageInfo.Format = "Page {0} of {1}";
            footerBand.Controls.Add(pageInfo);
        }
    }
}
vb
Imports System
Imports System.Web.Hosting
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWeb
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.DataAccess.Sql
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI

Namespace WebDashboard_CustomExport
    Partial Public Class [Default]
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            Dim dashboardFileStorage As New DashboardFileStorage("~/App_Data/Dashboards")
            ASPxDashboard1.SetDashboardStorage(dashboardFileStorage)

            Dim sqlDataSource As New DashboardSqlDataSource("SQL Data Source", "access97Connection")
            Dim query As SelectQuery = SelectQueryFluentBuilder.
                AddTable("SalesPerson").
                SelectAllColumns().
                Build("Sales Person")
            sqlDataSource.Queries.Add(query)

            Dim dataSourceStorage As New DataSourceInMemoryStorage()
            dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml())
            ASPxDashboard1.SetDataSourceStorage(dataSourceStorage)
        End Sub

        Protected Sub ASPxDashboard1_ConfigureDataConnection(ByVal sender As Object, _
                                                             ByVal e As ConfigureDataConnectionWebEventArgs)
            If e.ConnectionName = "access97Connection" Then
                Dim access97Params As New Access97ConnectionParameters()
                access97Params.FileName = HostingEnvironment.MapPath("~/App_Data/nwind.mdb")
                e.ConnectionParameters = access97Params
            End If
        End Sub
        Protected Sub ASPxDashboard1_CustomExport(ByVal sender As Object, _
                                                  ByVal e As CustomExportWebEventArgs)
            Dim report As XtraReport = TryCast(e.Report, XtraReport)
            Dim headerBand As New PageHeaderBand()
            report.Bands.Add(headerBand)

            Dim icon As New XRPictureBox()
            icon.ImageUrl = "~/App_Data/Images/dxlogo.png"
            icon.HeightF = 50
            icon.WidthF = 300
            headerBand.Controls.Add(icon)

            Dim customHeader As New XRLabel()
            customHeader.Text = "Additioanl Header Text"
            customHeader.LeftF = 300
            customHeader.WidthF = 300
            headerBand.Controls.Add(customHeader)

            Dim dateInfo As New XRPageInfo()
            dateInfo.PageInfo = pageInfo.DateTime
            dateInfo.Format = "Created at {0:h:mm tt dd MMMM yyyy}"
            dateInfo.TopF = 100
            dateInfo.WidthF = 200
            headerBand.Controls.Add(dateInfo)

            Dim userInfo As New XRPageInfo()
            userInfo.PageInfo = pageInfo.UserName
            userInfo.Format = "Current User: {0}"
            userInfo.TopF = 100
            userInfo.LeftF = 250
            userInfo.WidthF = 200
            headerBand.Controls.Add(userInfo)

            Dim footerBand As New PageFooterBand()
            report.Bands.Add(footerBand)
            Dim pageInfo_1 As New XRPageInfo()
            pageInfo_1.Format = "Page {0} of {1}"
            footerBand.Controls.Add(pageInfo_1)
        End Sub
    End Class
End Namespace
aspx
<%@ Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="WebDashboard_CustomExport.Default" %>

<%@ Register Assembly="DevExpress.Dashboard.v16.2.Web, Version=16.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.DashboardWeb" TagPrefix="dx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0;">
        <dx:ASPxDashboard ID="ASPxDashboard1" runat="server" Width="100%" Height="100%"
            AllowExportDashboardItems="True"
            OnConfigureDataConnection="ASPxDashboard1_ConfigureDataConnection"            
            OnCustomExport="ASPxDashboard1_CustomExport">
        </dx:ASPxDashboard>
    </div>
    </form>
</body>
</html>

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Report property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

web-forms-dashboard-add-custom-information-to-exported-dashboard/CS/WebDashboard_CustomExport/Default.aspx.cs#L37

csharp
protected void ASPxDashboard1_CustomExport(object sender, CustomExportWebEventArgs e) {
    XtraReport report = e.Report as XtraReport;
    PageHeaderBand headerBand = new PageHeaderBand();

web-forms-dashboard-add-custom-information-to-exported-dashboard/VB/WebDashboard_CustomExport/Default.aspx.vb#L36

vb
Protected Sub ASPxDashboard1_CustomExport(ByVal sender As Object, ByVal e As CustomExportWebEventArgs)
    Dim report As XtraReport = TryCast(e.Report, XtraReport)
    Dim headerBand As New PageHeaderBand()

See Also

CustomExportWebEventArgs Class

CustomExportWebEventArgs Members

DevExpress.DashboardWeb Namespace