Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 23, 2023, 9:05 AM EDT
Even though this is a old question.
You can use the built-in export functionality of the RadGridView control.
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 23, 2023, 9:07 AM EDT
In the code-behind, you can define the click event of the Export to Excel button as follows:
private void ExportToExcel_Click(object sender, RoutedEventArgs e) { var dialog = new SaveFileDialog(); dialog.Filter = "Excel (*.xlsx)|*.xlsx"; if (dialog.ShowDialog() == true) { var stream = new FileStream(dialog.FileName, FileMode.Create); gridView.ExportToXlsx(stream, new GridViewDocumentExportOptions()); stream.Close(); } }This code opens a file dialog and allows the user to choose a location to save the exported file. Then it creates a stream to write the exported data to the file. It calls the ExportToXlsx method of the RadGridView control to export the data to the stream in the Excel format. You can customize the export options by passing different parameters to the GridViewDocumentExportOptions object.
Tuhin PaulRank #7 · 71.9K reputationPosted Apr 23, 2023, 9:10 AM EDT
In a XAML form, RadGridView is a UI control that you can add to your application's window or page to display data in a grid format. It provides a flexible and customizable layout with support for various column types, cell templates, and data binding options. You can configure the appearance and behavior of the grid using XAML markup or code-behind. RadGridView also provides a rich set of event handlers and methods for interacting with the data, such as cell editing, row selection, filtering, and sorting. It also supports exporting data to various formats such as Excel, CSV, PDF, and HTML, as well as printing and data virtualization for better performance with large data sets.