X - Can i export all row except columns?

Hi,
 I want to export data from selected items but some columns are hidden, I want to ignore them. How can  do this?

10 Replies

VS Vijayarasan Sivanandham Syncfusion Team May 18, 2020 01:35 PM UTC

Hi Khanh Dang,

Thank you for contacting Syncfusion support.

Export to Excel: 
By default, entire grid will be exported to Excel. The selected items can only exported to excel by passing the SelectedItems to the ExportToExcel method. Please refer the following  user documentation for more details,

UG Link: https://help.syncfusion.com/windowsforms/datagrid/exporttoexcel#export-selected-items-to-excel 
By default, all the columns (including hidden columns) in SfDataGrid will be exported to Excel. In order to exclude some columns from exporting, use the ExcludeColumns field of the ExcelExportingOptions. Please refer the following user documentation for more details, 
UG Link: https://help.syncfusion.com/windowsforms/datagrid/exporttoexcel#exclude-columns-while-exporting

Export to PDF:

By default, entire grid will be exported to PDF. The selected items can only exported to the pdf by passing SelectedItems to ExportToPdf and ExportToPdfGrid methods. Please refer the following  user documentation for more details,

UG Link: https://help.syncfusion.com/windowsforms/datagrid/exporttopdf#export-selecteditems-to-pdf

 
By default, all the columns (including hidden columns) in SfDataGrid will be exported to PDF. In order to exclude some columns while exporting to PDF, use the ExcludeColumns property in PdfExportingOptions. Please refer the following  user documentation for more details,

UG Link:
https://help.syncfusion.com/windowsforms/datagrid/exporttopdf#exclude-columns-while-exporting

Regards,
Vijayarasan S 



TG The GridLock May 18, 2020 02:28 PM UTC

Thanks for the information Vijayarasan
is there an output function return ObservableCollection(Of ExpandoObject) but only with selecteditems and the columns displayed. (I mean an available function.) 


VS Vijayarasan Sivanandham Syncfusion Team May 19, 2020 03:02 PM UTC

Hi Khanh Dang,


Thanks for the update.


We are unable to understand your query. Can you please provide the more information related to your query.
 
It will be helpful for us to check on it and provide you the solution at the earliest.

Regards,
Vijayarasan S



TG The GridLock May 19, 2020 04:39 PM UTC

Hi Vijayarasan,
datagrid.selecteditems will return ObservableCollection(Of ExpandoObject) but it contains all cell value including cell in hidden columns.
Can I get datagrid.selecteditems but only the values in visible columns?


VS Vijayarasan Sivanandham Syncfusion Team May 20, 2020 06:13 PM UTC

Hi Khanh Dang,

Thanks for the update.

In SfDataGrid, SeletedItems retrieve underline binded collection. So, we do not get the cell values only for the visible column it contains all underline binded property of SfDataGrid.If you require only visible column you need to customize based on your requirement by using condition.

Regards,
Vijayarasan S
 



TG The GridLock May 21, 2020 05:34 AM UTC

Hi Vijayarasan,
I just think a certain function, for example:
sfdatagrid.view.records.selecteditems, hope to update soon.


VS Vijayarasan Sivanandham Syncfusion Team May 22, 2020 05:22 PM UTC

Hi Khanh Dang,

Thanks for the update.

Currently, we are analyzing your requirement of “Exporting all row except columns” in SfDataGrid. We will validate and update you the details on May 26, 2020.
 
 
We appreciate your patience until then. 
 
Regards, 
Vijayarasan S

 



VS Vijayarasan Sivanandham Syncfusion Team May 27, 2020 02:17 AM UTC

Hi Khanh Dang,

Thank you for your patience.

In our Source level provided selected item as underline business object. So, we do not get the cell values only for the visible column it contains all underline business object binded property of SfDataGrid. Your requirement can be achieved by using SfDataGrid.Columns[0].Visible property to create the customize collection for SelectedItem in SfDataGrid. Please refer the below code snippet,
 
GridNumericColumn gridTextColumn1 = new GridNumericColumn() { MappingName = "OrderID", HeaderText = "Order ID" ,Visible=false }; 
 
ExcelExportingOptions GridExcelExportingOptions = new ExcelExportingOptions(); 
 
List<string> hiddenColumns = new List<string>(); 
foreach (var column in sfDataGrid.Columns) 
{ 
                if (!column.Visible) 
                    hiddenColumns.Add(column.MappingName); 
} 
GridExcelExportingOptions.ExcludeColumns = hiddenColumns; 
 
 
sfDataGrid.ExportToExcel(sfDataGrid.SelectedItems, GridExcelExportingOptions, workBook.Worksheets[0]); 
 


Regards,
Vijayarasan S  
 



TG The GridLock May 27, 2020 05:06 PM UTC

Hi Vijayarasan,
I will try to try your code next time.
Thanks for the help!


SS Susmitha Sundar Syncfusion Team May 28, 2020 08:28 AM UTC

Hi  Khanh Dang,, 
 
Thanks for the update. 
 
We will wait to hear from you. 
 
Regards, 
Susmitha S 


Loader.
Up arrow icon