Skip to main content
All docs
V24.2

CustomizeExportDocumentEventArgs.GetItemData(String) Method

Returns multidimensional data for the specified dashboard item.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v24.2.Core.dll

Declaration

public MultiDimensionalData GetItemData(
    string dashboardItemName
)

Parameters

Name Type Description
dashboardItemName String

The dashboard item’s component name.

Returns

Type Description
MultiDimensionalData

The multidimensional data.

Remarks

Call the e.GetItemData method to obtain dashboard item’s data.

The code snippet below demonstrates how you can generate an XLSX document. The code uses Spreadsheet Document API to modify the generated document’s layout and content. This library is part of the DevExpress Office File API suite.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using DevExpress.DashboardCommon;
using DevExpress.DashboardCommon.ViewerData;
using DevExpress.Spreadsheet;
// ...
dashboardDesigner1.CustomizeExportDocument += DashboardDesigner1_CustomizeExportDocument;
// ...
private void DashboardDesigner1_CustomizeExportDocument(object sender, CustomizeExportDocumentEventArgs e){
  if (e.ExportAction == DashboardExportAction.ExportToExcel && e.ExcelExportOptions.Format == ExcelFormat.Xlsx) {
    CustomDashboardItem item = dashboardDesigner1.Dashboard.Items.FirstOrDefault(i => i.ComponentName == e.ItemComponentName) as CustomDashboardItem;

    if (item != null) {
        DevExpress.Spreadsheet.Workbook workbook = new DevExpress.Spreadsheet.Workbook();
        Worksheet worksheet = workbook.Worksheets[0];

        MultiDimensionalData itemData = e.GetItemData(e.ItemComponentName);
         CustomItemData customItemData = new CustomItemData(item, itemData);

        DashboardFlatDataSource flatData = customItemData.GetFlatData();
        IList<DashboardFlatDataColumn> columns = flatData.GetColumns();
        for (int colIndex = 0; colIndex < columns.Count; colIndex++){
            worksheet.Cells[0, colIndex].Value = columns[colIndex].DisplayName;
            worksheet.Cells[0, colIndex].FillColor = Color.LightGreen;
            worksheet.Cells[0, colIndex].Font.FontStyle = SpreadsheetFontStyle.Bold;
            int headerOffset = 1;
            for (int rowIndex = 0; rowIndex < flatData.Count; rowIndex++)
                worksheet.Cells[rowIndex + headerOffset, colIndex].Value = flatData.GetDisplayText(columns[colIndex].Name, rowIndex);
        }
        workbook.SaveDocument(e.Stream, DocumentFormat.Xlsx);
    }
  }
}

The following image demonstrates the resulting document:

Funnel custom export to Excel

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetItemData(String) method.

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.

See Also