且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用c#将excel文件导出到sql server

更新时间:2023-02-04 16:25:06

你必须确定规格/范围你的问题:



如果你想使用CSharp从Sql Server中的XL文件导入数据,那么:

你不需要MS Office

你不需要Accessdatabaseengine

你可能不应该使用OLE DB驱动程序而是使用本机sql server一个...





读取你的XL数据:

使用像(优秀的)ClosedXML [ ^ ]



一旦读取了数据,你就可以对你的sql server表进行非常经典的插入/更新
You must firm-up the specs/scope of your problem:

if you want to import data from XL files within Sql Server using CSharp then :
you don't need MS Office
you don't need Accessdatabaseengine
and you should probably not use the OLE DB driver but the native sql server one...


To read your XL data:
use a library like (the excellent) ClosedXML[^]

Once the data is read you soimply do very classic Insert/Updates to your sql server table(s)