Export to CSV
RELATED VIDEOS | |
---|---|
Exporting to CSV with RadGridView for WinForms In this video, you will learn how to export RadGridView for WinForms to the CSV file format. |
![]() |
Overview
This method offers excellent export performance. It creates a csv file and supports formatting events to allow customizing exported data.
The CSV export functionality is located in the TelerikData.dll assembly. You need to include the following namespaces in order to access the types contained in TelerikData:
- Telerik.WinControls.Data
- Telerik.WinControls.UI.Export>
Exporting Data
Initialize ExportToCSV object
Before running export to CSV, you have to initialize the ExportToCSV class. The constructor takes one parameter: the RadGridView that will be exported:
ExportToCSV initialization
File Extension
This property allows for changing the default (*.csv) file extension of the exported result file:
Setting the file extension
Hidden Columns and Rows Option
You can choose if the hidden columns and rows should be exported through HiddenColumnOption and HiddenRowOption properties. Please, note that these properties use the standard enums and include the *ExportAsHidden *option, which is not supported by CSV format. Setting that option will not affect the export at all.
ExportAlways
DoNotExport (default)
ExportAsHidden (not supported in csv)
Summaries export option
You can use SummariesExportOption property to specify how to export summary items. There are four options to choose from:
ExportAll (default)
ExportOnlyTop
ExportOnlyBottom
DoNotExport
Setting summaries to export
RunExport method
Exporting data to CSV file is done through the RunExport method of the ExportToCSV
object. The RunExport method accepts the following parameter:
- fileName: the name of the exported file
Export to CVS format
Events
CSVCellFormating event
It gives access to a single cell’s element that allows you to replace the actual value for every cell related to the exported RadGridView:
Handling the CSVCellFormatting event
CSVTableCreated event:
It can be used together with the public method AddCustomCSVRow. It allows for adding and formatting new custom rows on the top of the csv file :