如何在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[^]