This example exports GridControl data to a CSV file.
Follow the steps below to export GridControl data in code-behind:
- Reference the
DevExpress.WinUI.Grid.Printing
andDevExpress.WinUI.Printing
namespaces. - Create a GridControlPrinter instance that contains the GridControl you want to export. Pass the created GridControlPrinter instance to the PrintableLink's constructor as a parameter to create a PrintableLink instance. The PrintableLink class creates a link between a GridControl and an exported document.
- Call a CreateDocument* method to create a new document. Then, call an ExportTo* method according to a file format you need.
You can export GridControl data to the following formats:
Format | Methods |
---|---|
Csv | ExportToCsv |
Docx | ExportToDocx |
Html | ExportToHtml |
Image | ExportToImage |
ExportToMail | |
Mht | ExportToMht |
ExportToPdf | |
Rtf | ExportToRtf |
Text | ExportToText |
Xls | ExportToXls |
Xlsx | ExportToXlsx |
Xps | ExportToXps |
(you will be redirected to DevExpress.com to submit your response)