Skip to content

DevExpress-Examples/winforms-grid-customize-data-aware-export-output

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Data Grid - Customize data-aware export output

This example shows how to export the grid's data to a file in XLSX format and customize the output. The example uses the GridControl.ExportToXlsx method, which takes a parameter (XlsxExportOptionsEx) that regulates export settings and behavior, and implements events that allow you to add a header and footer to the export output, customize cells, add rows, etc.

  • The XlsxExportOptionsEx.CustomizeSheetHeader event is handled to add a header with custom information to the generated Microsoft Excel document. The e.ExportContext.AddRow, e.ExportContext.InsertImage, and e.ExportContext.MergeCells methods are used to add rows with the company name and contact information, insert the company logo, and merge certain cells. Cell formatting is specified using objects of the XlFormattingObject class.

  • The XlsxExportOptionsEx.CustomizeCell event is handled to replace values in the Discontinued column with special symbols. The e.ColumnFieldName event parameter identifies the column. The e.Value parameter is used to substitute certain cell values. The e.Handled parameter is set to true to apply the changes made.

  • The XlsxExportOptionsEx.AfterAddRow event is handled to merge cells in rows that correspond to the grid's group rows. The e.ExportContext.MergeCells method is used to merge cells. The e.DataSourceRowIndex event parameter returns negative values for group rows. The e.DocumentRow parameter specifies the current row in the export output.

  • The XlsxExportOptionsEx.CustomizeSheetFooter event is handled to add a footer to the document. The event handler uses the e.ExportContext.AddRow method to add two rows to the output document. Format settings are specified using objects of the XlFormattingObject class.

  • The XlsxExportOptionsEx.CustomizeSheetSettings event is handled to specify export settings. The e.ExportContext.SetFixedHeader method is used to anchor the output document's header to the top, and to set the fixed header height. The e.ExportContext.AddAutoFilter method is used to add the AutoFilter button to cells that correspond to grid column headers.

Files to Review

Documentation

See Also


Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)