Click here to Skip to main content
15,895,538 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello all,
i want to export data from excel sheet to database but first i want to filter the data so i want to store that data in List to do some edit then pass it to the table

i use SQl server and Entity framework
i fill the excel sheet on data grid, then i tried to import the data from the data grid to the list but the data grid has no static column header name, because the excel may have many columns i will pick what i need.

the data is shown in the datagrid.

my list of object is :
List<devicet> Li = new List<devicet>();
and the table DeviceT has 8 rows and the imported excel sheet has just 5.
i want to fill the correct column in the correct place on a list

What I have tried:

i export the data to datagrid, i cannot export data from datagrid to list
Posted
Updated 30-May-18 7:37am

1 solution

If you were to search CodeProject for solution, you would find this article (among others):

CSV/Excel File Parser - A Revisit[^]

If column names aren't included in the data, the code cited above adds column names in the format 'Column N', where 'N' is the ordinal position of the column.
 
Share this answer
 
Comments
Member 13199484 31-May-18 0:35am    
thanks its very helpful, but still i need to know how to fill a list from datagrid
#realJSOP 31-May-18 12:11pm    
If you're doing WPF correctly, the datagrid should already be bound to a collection, and should be accessible via the ItemsSource property.
Member 13199484 31-May-18 12:44pm    
actually, i use
datagrid.itemssource=EFM.Tablename.tolist();
i cannot bind it back to list using itemsource
#realJSOP 31-May-18 18:46pm    
Is your collection an ObservableCollection?
Member 13199484 2-Jun-18 12:12pm    
no, it is not
sorry for the late reply

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900