Wpf将excel文件导出到对象列表 [英] Wpf export excel file to list of object

查看:147
本文介绍了Wpf将excel文件导出到对象列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

i想要将数据从excel表导出到数据库但是首先我要过滤数据,所以我想将这些数据存储在List中进行一些编辑然后将其传递给表



i使用SQl服务器和实体框架

i填写数据网格上的excel表格,然后我尝试将数据从数据网格导入列表,但数据网格没有静态列标题名称,因为excel可能有很多列我会选择我需要的。



数据显示在datagrid中。



我的对象列表是:

List< devicet> Li =新列表< devicet>();

和表DeviceT有8行,导入的excel表只有5。

i想要填写正确的列正确的位置在列表中



我尝试过:



i export数据到datagrid,我无法将数据从datagrid导出到列表

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

推荐答案

如果你要搜索CodeProject的解决方案,你会发现这篇文章(以及其他): br $> b $ b

CSV / Excel文件分析器 - 重访 [ ^ ]



如果数据中不包含列名,则上面引用的代码会以列N的格式添加列名,其中'N'是列的序数位置。
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.


这篇关于Wpf将excel文件导出到对象列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆