如何在C#中读取excel文件并将数据存储到sql server数据库表中? [英] how to read excel files in C# and store the data into sql server database table?

查看:559
本文介绍了如何在C#中读取excel文件并将数据存储到sql server数据库表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中读取excel文件并将数据存储到sql server数据库表中?

数据库表列和excel列的序列不同。

how to read excel files in C# and store the data into sql server database table?
sequence of database table columns and excel columns is different.

推荐答案

查看我过去的回答:导入excel到db with file path [ ^ ]。我建议使用 SqlBulkCopy类 [ ^ ],它可以启用列映射。



请参阅: SqlBulkCopy.ColumnMappings属性 [ ^ ]

SqlBulkCopyColumnMappingCollection Class [ ^ ]
See my past answer: import excel to db with file path[^]. There i suggested to use SqlBulkCopy class[^], which enables columns mapping.

Please, see: SqlBulkCopy.ColumnMappings Property[^]
SqlBulkCopyColumnMappingCollection Class[^]


这篇关于如何在C#中读取excel文件并将数据存储到sql server数据库表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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