WinUI

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class DataGridExcelExportOptions

    Show / Hide Table of Contents

    Class DataGridExcelExportOptions

    Represents a class that provides various properties and event handlers to customize the exporting of SfDataGrid data to an Excel file.

    Inheritance
    System.Object
    DataGridExcelExportOptions
    Namespace: Syncfusion.UI.Xaml.DataGrid.Export
    Assembly: Syncfusion.GridExport.WinUI.dll
    Syntax
    public class DataGridExcelExportOptions : Object

    Constructors

    DataGridExcelExportOptions()

    Initializes a new instance of the class.

    Declaration
    public DataGridExcelExportOptions()

    Fields

    ExcludedColumns

    Gets or sets a list of columns that will be excluded from the export.

    Declaration
    public List<string> ExcludedColumns
    Field Value
    Type Description
    System.Collections.Generic.List<System.String>

    Properties

    CanExportColumnWidth

    Gets or sets a value indicating whether the data grid column width should be used during export.

    Declaration
    public bool CanExportColumnWidth { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the data grid column width is applied to the exported Excel sheet; otherwise, false. When this property is set to false, the default column width is applied to the exported sheet. The default value is true.

    CanExportMergedCells

    Gets or sets a value indicating whether merged cells should be exported.

    Declaration
    public bool CanExportMergedCells { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if merged cells should be exported; otherwise, false. The default value is false.

    CanExportStackedHeaders

    Gets or sets a value indicating whether stacked headers should be exported.

    Declaration
    public bool CanExportStackedHeaders { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if stacked headers should be exported; otherwise, false. The default value is false.

    CanExportUnboundRows

    Gets or sets a value indicating whether unbound rows should be exported.

    Declaration
    public bool CanExportUnboundRows { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if unbound rows should be exported; otherwise, false. The default value is false.

    CellsExportHandler

    Gets or sets a handler for customizing the exporting of individual cells to Excel.

    Declaration
    public DataGridCellExcelExport CellsExportHandler { get; set; }
    Property Value
    Type Description
    DataGridCellExcelExport

    A delegate that is called for each cell being exported, allowing for customization of the export options for that cell.

    Examples
    var options = new DataGridExcelExportOptions();
    options.CellsExportHandler = CellsExportHandler;
    private void CellsExportHandler(object sender, DataGridCellExcelExportOptions e)
    {
        if (e.ColumnName == "BirthDate")
        {
            e.ExportMode = ExportMode.Text;
        }
    }

    Columns

    Gets a list of columns, excluding any specified in the ExcludedColumns property.

    Declaration
    public List<string> Columns { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<System.String>

    DefaultColumnWidth

    Gets or sets the default column width for the exported Excel sheet.

    Declaration
    public double DefaultColumnWidth { get; set; }
    Property Value
    Type Description
    System.Double

    DefaultRowHeight

    Gets or sets the default row height for the exported Excel sheet.

    Declaration
    public double DefaultRowHeight { get; set; }
    Property Value
    Type Description
    System.Double

    DetailsViewExportHandler

    Gets or sets a handler for customizing the exporting of details views to Excel.

    Declaration
    public DataGridDetailsViewExcelExport DetailsViewExportHandler { get; set; }
    Property Value
    Type Description
    DataGridDetailsViewExcelExport

    A delegate that is called for each details view being exported, allowing for customization of the export options for that view.

    Examples
    var options = new DataGridExcelExportOptions();
    options.DetailsViewExportHandler = DetailsViewExportHandler;
    private void DetailsViewExportHandler(object sender, DataGridDetailsViewExcelExportOptions e)
    {
        e.ExcludedColumns.Add("OrderID");
    }

    ExcelVersion

    Gets or sets the Excel version for the exported workbook.

    Declaration
    public ExcelVersion ExcelVersion { get; set; }
    Property Value
    Type Description
    ExcelVersion

    One of the ExcelVersion enumeration values that specifies the Excel version. The default value is Excel2007.

    ExportMode

    Gets or sets the export mode for the data.

    Declaration
    public ExportMode ExportMode { get; set; }
    Property Value
    Type Description
    ExportMode

    One of the ExportMode enumeration values that specifies how the data should be exported to Excel. The default value is Value.

    GridExportHandler

    Gets or sets a handler for customizing the styles of header, table summary, group summary, and caption summary rows during export to Excel.

    Declaration
    public DataGridExcelExport GridExportHandler { get; set; }
    Property Value
    Type Description
    DataGridExcelExport

    A delegate that is called for each cell in the specified rows, allowing for customization of the style options for that cell.

    Examples
    var options = new DataGridExcelExportOptions();
    options.GridExportHandler = GridExportHandler;
    private void GridExportHandler(object sender, DataGridExcelExportStartOptions e)
    {
        if (e.CellType == ExportCellType.HeaderCell)
        {
            e.Style.Color = Color.Red;
            e.Style.Font.Color = ExcelKnownColors.White;
            e.Handled = true;
        }
    }

    ShowOutlines

    Gets or sets a value indicating whether groups in the export should include expand/collapse options.

    Declaration
    public bool ShowOutlines { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if outlining is enabled; otherwise, false. The default value is true.

    Remarks

    When this property is set to true, outlining is enabled and no indentation is maintained. If the grid contains a details view definition, this property is set to true internally.

    StartColumnIndex

    Gets or sets the starting column index for the exported data in the Excel sheet.

    Declaration
    public int StartColumnIndex { get; set; }
    Property Value
    Type Description
    System.Int32

    StartRowIndex

    Gets or sets the starting row index for the exported data in the Excel sheet.

    Declaration
    public int StartRowIndex { get; set; }
    Property Value
    Type Description
    System.Int32
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved