Class DataGridToExcelConverter
Provides the base implementation to export the SfDataGrid to Excel.
Inheritance
Inherited Members
Namespace: Syncfusion.WinForms.DataGridConverter
Assembly: Syncfusion.SfDataGridConverter.WinForms.dll
Syntax
public class DataGridToExcelConverter
Remarks
It provides the set of public and virtual methods to customize the rows and columns while exporting.
Constructors
DataGridToExcelConverter()
Declaration
public DataGridToExcelConverter()
Fields
ColumnFormat
Declaration
protected Dictionary<GridColumn, string> ColumnFormat
Field Value
Type |
---|
System.Collections.Generic.Dictionary<GridColumn, System.String> |
Properties
ExcelColumnIndex
Gets or sets the column index of ExcelSheet which keeps track of the Excel column index while exporting.
Declaration
protected int ExcelColumnIndex { get; set; }
Property Value
Type |
---|
System.Int32 |
ExcelRowIndex
Gets or sets the row index of ExcelSheet which keeps track of the Excel row index while exporting.
Declaration
protected int ExcelRowIndex { get; set; }
Property Value
Type |
---|
System.Int32 |
Methods
ExportBorderStyle(GridBorder, IBorder)
Exports the border settings from grid border into excel sheet border.
Declaration
protected virtual void ExportBorderStyle(GridBorder cellBorder, IBorder range)
Parameters
Type | Name | Description |
---|---|---|
GridBorder | cellBorder | Grid border to copy. |
IBorder | range | Destination excel border. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | if |
ExportBorderStyles(CellStyleInfo, IRange)
Exports the border styles to excel.
Declaration
protected virtual void ExportBorderStyles(CellStyleInfo gridCell, IRange range)
Parameters
Type | Name | Description |
---|---|---|
CellStyleInfo | gridCell | The cell style. |
IRange | range | Destination excel sheet range. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | if |
ExportColumnStylesToExcel(CellStyleInfo, IRange, ExcelExportingOptions)
Exports SfDataGrid column styles to Excel.
Declaration
protected virtual void ExportColumnStylesToExcel(CellStyleInfo styleInfo, IRange range, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
CellStyleInfo | styleInfo | Specifies the CellStyleInfo of SfDataGrid. |
IRange | range | Specifies the range of Excel sheet. |
ExcelExportingOptions | excelExportingOptions | Specifies the excel exporting options to export. |
ExportDetailsViewDataGridToExcel(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions)
Declaration
protected virtual void ExportDetailsViewDataGridToExcel(SfDataGrid sourceDataGrid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | sourceDataGrid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions |
ExportDetailsViewToExcel(SfDataGrid, IWorksheet, ExcelExportingOptions, Object, IPropertyAccessProvider)
Export DetailsViewDefinition to Excel.
Declaration
protected virtual void ExportDetailsViewToExcel(SfDataGrid parentDataGrid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, object rec, IPropertyAccessProvider propertyAccessProvider)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | parentDataGrid | Specifies the SfDataGrid. |
IWorksheet | sheet | Specifies the WorkSheet. |
ExcelExportingOptions | excelExportingOptions | Specifies the exporting options. |
System.Object | rec | Specifies the RecordEntry. |
IPropertyAccessProvider | propertyAccessProvider | Specifies the PropertyAccessProvider. |
ExportFreezePanesToExcel(SfDataGrid, IWorksheet, ExcelExportingOptions)
Exports the freezing range to Excel
Declaration
protected virtual void ExportFreezePanesToExcel(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | Specifies the SfDataGrid. |
IWorksheet | sheet | Specifies the sheet to export. |
ExcelExportingOptions | excelExportingOptions | Specifies the excel exporting options to export. |
ExportGridStylesToExcel(CellStyleInfo, IRange, ExcelExportingOptions)
Exports SfDataGrid styles to Excel.
Declaration
protected virtual void ExportGridStylesToExcel(CellStyleInfo styleInfo, IRange range, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
CellStyleInfo | styleInfo | Specifies the CellStyleInfo of SfDataGrid. |
IRange | range | Specifies the range of Excel sheet. |
ExcelExportingOptions | excelExportingOptions | Specifies the excel exporting options to export. |
ExportGroupCaptionToExcel(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions, Group)
Declaration
protected virtual void ExportGroupCaptionToExcel(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, Group group)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions | |
Group | group |
ExportGroupSummariesToExcel(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions, Group)
Declaration
protected virtual void ExportGroupSummariesToExcel(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, Group group)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions | |
Group | group |
ExportGroupToExcel(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions, Group)
Declaration
protected virtual void ExportGroupToExcel(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, Group group)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions | |
Group | group |
ExportHeadersToExcel(SfDataGrid, IWorksheet, ExcelExportingOptions)
Declaration
protected virtual void ExportHeadersToExcel(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions |
ExportImageColumnToExcel(IRange, Object, Object, GridColumn)
Export GridImageColumn to excel.
Declaration
protected virtual void ExportImageColumnToExcel(IRange excelRange, object record, object cellValue, GridColumn gridColumn)
Parameters
Type | Name | Description |
---|---|---|
IRange | excelRange | Specifies the excel range. |
System.Object | record | Specifies the record. |
System.Object | cellValue | Specifies the cell value. |
GridColumn | gridColumn |
ExportNumberFormatToExcel(IRange, IStyle, GridColumn, Object)
Export NumberFormat to Excel.
Declaration
protected virtual void ExportNumberFormatToExcel(IRange excelrange, IStyle gridColumnFormat, GridColumn gridColumn, object cellValue)
Parameters
Type | Name | Description |
---|---|---|
IRange | excelrange | The Excel range to which the column format will be exported. |
IStyle | gridColumnFormat | Specifies the Excel number format. |
GridColumn | gridColumn | Specifies the GridColumn. |
System.Object | cellValue | Specifies the cell value. |
ExportRecordCellToExcel(SfDataGrid, IRange, ExcelExportingOptions, Object, IPropertyAccessProvider, GridColumn)
Declaration
protected virtual void ExportRecordCellToExcel(SfDataGrid grid, IRange excelrange, ExcelExportingOptions excelExportingOptions, object record, IPropertyAccessProvider propertyAccessProvider, GridColumn gridColumn)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IRange | excelrange | |
ExcelExportingOptions | excelExportingOptions | |
System.Object | record | |
IPropertyAccessProvider | propertyAccessProvider | |
GridColumn | gridColumn |
ExportRecordsToExcel(SfDataGrid, IWorksheet, ExcelExportingOptions, IEnumerable, IPropertyAccessProvider, Group)
Declaration
protected virtual void ExportRecordsToExcel(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, IEnumerable records, IPropertyAccessProvider propertyAccessProvider, Group group)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions | |
System.Collections.IEnumerable | records | |
IPropertyAccessProvider | propertyAccessProvider | |
Group | group |
ExportRecordToExcel(SfDataGrid, IWorksheet, ExcelExportingOptions, Object, Int32, IPropertyAccessProvider)
Export record to excel.
Declaration
protected virtual void ExportRecordToExcel(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, object record, int startColumnIndex, IPropertyAccessProvider propertyAccessProvider)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | Specifies the SfDataGrid. |
IWorksheet | sheet | Specifies the WorkSheet. |
ExcelExportingOptions | excelExportingOptions | Specifies the instance of class |
System.Object | record | Specifies the record. |
System.Int32 | startColumnIndex | Specifies the startColumnIndex. |
IPropertyAccessProvider | propertyAccessProvider | Specifies the property access provider. |
ExportRowStyle(IRange, IStyle, Int32)
Export row style to Excel.
Declaration
protected virtual void ExportRowStyle(IRange excelRange, IStyle style, int rowIndex)
Parameters
Type | Name | Description |
---|---|---|
IRange | excelRange | Specifies the Excel range. |
IStyle | style | Specifies the style. |
System.Int32 | rowIndex | Specifies the row index. |
ExportStackedHeadersToExcel(SfDataGrid, IWorksheet, ExcelExportingOptions)
Declaration
protected virtual void ExportStackedHeadersToExcel(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions exportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IWorksheet | sheet | |
ExcelExportingOptions | exportingOptions |
ExportStackedHeaderToExcel(SfDataGrid, IWorksheet, ExcelExportingOptions, StackedHeaderRow)
Declaration
protected virtual void ExportStackedHeaderToExcel(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions exportingOptions, StackedHeaderRow stackedHeaderRow)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IWorksheet | sheet | |
ExcelExportingOptions | exportingOptions | |
StackedHeaderRow | stackedHeaderRow |
ExportSummaryCellToExcel(SfDataGrid, IRange, ExportCellType, String, Object, String, ExcelExportingOptions)
Declaration
protected virtual void ExportSummaryCellToExcel(SfDataGrid grid, IRange summaryRange, ExportCellType exportCellType, string summaryDisplayText, object exportNodeEntry, string columnName, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IRange | summaryRange | |
ExportCellType | exportCellType | |
System.String | summaryDisplayText | |
System.Object | exportNodeEntry | |
System.String | columnName | |
ExcelExportingOptions | excelExportingOptions |
ExportTableSummariesToExcel(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions, VerticalPosition)
Declaration
protected virtual void ExportTableSummariesToExcel(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, VerticalPosition position)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions | |
VerticalPosition | position |
ExportTableSummaryToExcel(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions, SummaryRecordEntry)
Declaration
protected virtual void ExportTableSummaryToExcel(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, SummaryRecordEntry summaryRecordEntry)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions | |
SummaryRecordEntry | summaryRecordEntry |
ExportToExcel(SfDataGrid, ICollectionViewAdv, ExcelExportingOptions)
Declaration
public virtual ExcelEngine ExportToExcel(SfDataGrid grid, ICollectionViewAdv view, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
ExcelExportingOptions | excelExportingOptions |
Returns
Type |
---|
ExcelEngine |
ExportToExcel(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions)
Declaration
public virtual void ExportToExcel(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions |
ExportToExcel(SfDataGrid, ObservableCollection<Object>, ExcelExportingOptions)
Declaration
public virtual ExcelEngine ExportToExcel(SfDataGrid grid, ObservableCollection<object> selectedItems, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
System.Collections.ObjectModel.ObservableCollection<System.Object> | selectedItems | |
ExcelExportingOptions | excelExportingOptions |
Returns
Type |
---|
ExcelEngine |
ExportToExcel(SfDataGrid, ObservableCollection<Object>, IWorksheet, ExcelExportingOptions)
Declaration
public virtual void ExportToExcel(SfDataGrid grid, ObservableCollection<object> selectedItems, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
System.Collections.ObjectModel.ObservableCollection<System.Object> | selectedItems | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions |
ExportToExcel(SfDataGrid, String, ICollectionViewAdv, ExcelExportingOptions)
Declaration
public virtual void ExportToExcel(SfDataGrid grid, string excelFileName, ICollectionViewAdv view, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
System.String | excelFileName | |
ICollectionViewAdv | view | |
ExcelExportingOptions | excelExportingOptions |
ExportToExcel(SfDataGrid, String, ObservableCollection<Object>, ExcelExportingOptions)
Declaration
public virtual void ExportToExcel(SfDataGrid grid, string excelFileName, ObservableCollection<object> selectedItems, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
System.String | excelFileName | |
System.Collections.ObjectModel.ObservableCollection<System.Object> | selectedItems | |
ExcelExportingOptions | excelExportingOptions |
ExportToExcelWorksheet(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions)
Declaration
protected virtual void ExportToExcelWorksheet(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions |
ExportUnboundRowCellToExcel(SfDataGrid, IRange, ExcelExportingOptions, GridUnboundRow, GridColumn)
Declaration
protected virtual void ExportUnboundRowCellToExcel(SfDataGrid grid, IRange excelrange, ExcelExportingOptions excelExportingOptions, GridUnboundRow gridUnboundRow, GridColumn gridColumn)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IRange | excelrange | |
ExcelExportingOptions | excelExportingOptions | |
GridUnboundRow | gridUnboundRow | |
GridColumn | gridColumn |
ExportUnboundRowsToExcel(SfDataGrid, ICollectionViewAdv, IWorksheet, ExcelExportingOptions, VerticalPosition, Boolean, ObservableCollection<GridUnboundRow>)
Declaration
protected virtual void ExportUnboundRowsToExcel(SfDataGrid grid, ICollectionViewAdv view, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, VerticalPosition position, bool belowSummary, ObservableCollection<GridUnboundRow> unBoundRows = null)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
ICollectionViewAdv | view | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions | |
VerticalPosition | position | |
System.Boolean | belowSummary | |
System.Collections.ObjectModel.ObservableCollection<GridUnboundRow> | unBoundRows |
ExportUnboundRowToExcel(SfDataGrid, IWorksheet, ExcelExportingOptions, GridUnboundRow)
Declaration
protected virtual void ExportUnboundRowToExcel(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, GridUnboundRow gridUnboundRow)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions | |
GridUnboundRow | gridUnboundRow |
GetCellValue(Object, IPropertyAccessProvider, GridColumn, ExportMode)
Gets record cell value to export.
Declaration
protected virtual object GetCellValue(object record, IPropertyAccessProvider propertyAccessProvider, GridColumn gridColumn, ExportMode exportMode)
Parameters
Type | Name | Description |
---|---|---|
System.Object | record | Specifies the record. |
IPropertyAccessProvider | propertyAccessProvider | Specifies the property access provider. |
GridColumn | gridColumn | Specifies the GridColumn. |
ExportMode | exportMode | Specifies the export mode. |
Returns
Type | Description |
---|---|
System.Object | Returns the cell value to export. |
GetExcelStartColumnIndex(SfDataGrid, IWorksheet, ExcelExportingOptions, Group)
Method returns the start column index in excel.
Declaration
protected virtual int GetExcelStartColumnIndex(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions, Group group = null)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | Specifies the SfDataGrid. |
IWorksheet | sheet | Specifies the WorkSheet. |
ExcelExportingOptions | excelExportingOptions | Specifies the exporting option. |
Group | group | Specifies the Group. |
Returns
Type | Description |
---|---|
System.Int32 | Returns start column index of excel. |
InitializeCellStyle(SfDataGrid, IWorksheet, ExcelExportingOptions)
Declaration
protected virtual void InitializeCellStyle(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions |
SetColumnWidth(SfDataGrid, IWorksheet, ExcelExportingOptions)
Declaration
protected virtual void SetColumnWidth(SfDataGrid grid, IWorksheet sheet, ExcelExportingOptions excelExportingOptions)
Parameters
Type | Name | Description |
---|---|---|
SfDataGrid | grid | |
IWorksheet | sheet | |
ExcelExportingOptions | excelExportingOptions |
SetIndentColumnWidth(IWorksheet, Int32, Int32)
Sets the indent column width.
Declaration
protected virtual void SetIndentColumnWidth(IWorksheet sheet, int start, int end)
Parameters
Type | Name | Description |
---|---|---|
IWorksheet | sheet | Specifies the WorkSheet. |
System.Int32 | start | Specifies the start indent column index |
System.Int32 | end | Specifies the end indent column index |