Export Data in a Group to Excel from GridView
The Kettic GridView .NET WinForms control supports not only exporting data to Excel, but also exporting data in a group from the grouped Kettic GridView to Excel. This is achieved by using the context menu and the C# API included in it. This feature neednât the MS Office installation, however, allows the exported Excel file being read in MS Excel spreadsheet 2003 and higher versions. This article will talk about how to export data in a group to Excel in C#.NET
How to Export Data in a Group to Excel in C#.NET
First, we need to create the Kettic ContextMenu and get the group header row through the methods, MouseDown and GetGridGroupHeaderRowElement. When determining the clicked group row, we can get the child rows of the grouped rows. The following is the C# code that demonstrates how to achieve this.
The ExportToExcel method does not support data exporting to Excel when there is no data specified, so we need to use the ExportToExcelML C# class with DoNotExport for HiddenRowOption property.
In the Kettic GridView.Rows collection, we need to mark the rows matching that of the child collection through changing the Visible property to True and disable the rest. And then change the HiddenRowOption to DoNotExport to export the Kettic GridView. The C# code below shows how to accomplish this.
The C# code below will allows the users to get the text from the GroupRowHeader.
|
UI Controlsfor Windows Forms .NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI DesignWinForms UI Controls WinForms Buttons UI Control WinForms Calendar UI ControlWinForms Carousel UI ControlWinForms Chart UI ControlWinForms Clock UI ControlCommandBar UI ControlWinForms Dock UI ControlDesktop Alert UI ControlDropDown List UI ControlWinForms Editor UI ControlForms and Dialogs UI ControlWinForms GridView UI ControlGridView - Get Started in C#GridView - PropertiesGridView - ColumnGridView - RowGridView - CellsGridView - EditorsGridView - Context MenuGridView - Populating with DataGridView - Hierarchical GridGridView - SelectionGridView - ScrollingGridView - SortingGridView - GroupingGridView - FilteringGridView - Expression EditorInsert/ Update/ Delete RecordsGridView - View DefinitionTableColumn GroupGridView - Exporting DataExport to ExcelExport Data in a Group to ExcelExport to CSVExport to HTMLExport to PDFStyling and AppearanceThemeImageAlternating Row ColorGridView - LocalizationSave and Load LayoutGridView - Print SupportPrint StylePrint EventsWinForms ListView UI ControlWinForms Menu UI ControlWinForms ComboBox UI ControlWinForms PageView UI ControlPanels and Labels UI ControlWinForms Panorama UI ControlWinForms PDFViewer UI ControlWinForms Property Grid UI ControlWinForms Ribbon UI ControlWinForms PivotGrid UI ControlWinForms RichTextBox UI ControlWinForms Rotator UI ControlWinForms Scheduler UI ControlWinForms Shortcuts UI ControlWinForms SpellChecker UI ControlWinForms Track & Status UI ControlWinForms TreeView UI ControlWinForms Wizard UI ControlWinForms Test UI ControlWinForms Theme UI Control |